函数声明表达式
hoisted(); // logs "foo"
function hoisted() {
console.log("foo");
}
function操作符
var math = {
'factorial': function factorial(n) {
if (n <= 1)
return 1;
return n * factorial(n - 1);
}
};
Function 构造函数
// Example can be run directly in your JavaScript console
// Create a function that takes two arguments and returns the sum of those arguments
var adder = new Function('a', 'b', 'return a + b');
// Call the function
adder(2, 6);
// > 8