[JavaScript]functionexpression

(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


阅读更多
个人分类: JavaScript
想对作者说点什么? 我来说一句

没有更多推荐了,返回首页

关闭
关闭
关闭