【发布时间】:2013-06-05 20:35:36
【问题描述】:
var ninja = {
yell: function yellaaa(n){
return n > 0 ? yell(n-1) + "a" : "hiy";
}
};
var samurai = { yell: ninja.yell };
var ninja = null;
assert( samurai.yell(4) == "hiyaaaa", "The method correctly calls itself." );
我想问一下,为什么在ninja.null被删除后仍然可以调用samurai.yell? 这是否意味着给对象方法一个名字,副本就变成了“深拷贝”,而匿名函数只会进行“浅拷贝”?
谢谢
【问题讨论】:
-
The tutorial is showing that removing references to objects does not delete the object itself.如切尔尼夫提到的答案可以在这里找到stackoverflow.com/questions/16986234/purpose-of-variable -
是的,非常感谢!
标签: javascript function object methods anonymous