Function defined in several ways

Many forms function definition. Common are the following categories.

1. custom function (function name)

function fn(){};

2. function expressions (anonymous function)

var fun =function(){};

3. Use new Function ( 'n1', 'n2', 'n3', ........, 'function body')

var fun =new Function('a','b','c','console.log(a+b+c)');
fun(1,2,3);

   3.1Function must all format string

   The third way 3.2 low efficiency, so rarely used

4. Function All functions are instance objects, also belong to the object function

var fun =new Function('a','b','c','console.log(a+b+c)');
fun(1,2,3);
console.dir(fun);
console.log(f instanceof Object);

Therefore, the specific object which can be summarized as the relationship shown in FIG.

The same logic can be bypassed to the object constructor common property of the object inheritance ES5.

Guess you like

Origin www.cnblogs.com/omiturix/p/11761774.html