JavaScript中"this"关键字
在方法中, this表示该方法所属的对象
var foo = {
bar: function() { return this; }
};
console.log(foo === foo.bar());
// true
如果单独使用, this表示全局对象
console.log(this);
// Window{decodeURIComponent: ƒ, postMessage: ƒ,...
原创
2019-06-30 12:52:50 ·
110 阅读 ·
0 评论