放假没事儿看了看mootools的代码, 觉得很过瘾。 paste 一小块过来:
var Hash = new Native({ name: 'Hash', initialize: function(object){ if ($type(object) == 'hash') object = $unlink(object.getClean()); for (var key in object) this[key] = object[key]; return this; } });
有兴趣的可以一起讨论下这里面的 this 引用的是谁? 别急着下结论, 最好说说为什么会引用它 :)