(function () {}) === (function () {})
//=> false
Like arrays, every time you evaluate an expression to produce a function, you get a new function that is not identical to any other function, even if you use the same expression to generate it. “Function” is a reference type.
从上面的理论我们可以得到下面的有趣的结果
function test(){
console.log('test');
}
var copy = test;
test();// output : test
copy(); // output : test
test = function(){
console.log('another test');
}
test();// output : another test
copy(); // output : test
本文探讨了函数作为引用类型的特点,解释了即使使用相同表达式创建的函数也不会彼此相等的原因,并通过实例展示了变量间函数赋值的行为。

被折叠的 条评论
为什么被折叠?



