文章 评论 浏览 29
@yangjunfocus
var _ = function(obj) { console.log(this) if (!(this instanceof _)) return new _(obj); this._wrapped = obj; }; _([1, 2, 3])
查看打印结果为:
第一次 this 指向 window第二次 this 指向 _ 的实例
文章 0 评论 0
接受
@yangjunfocus
查看打印结果为:
第一次 this 指向 window
第二次 this 指向 _ 的实例
underscore 系列之如何写自己的 underscore