程序媛小琦(对于this的认识)
this
1.默认绑定
(有this,前面没有任何元素)不带任何修饰的函数进行调用的,只能采用默认绑定,this指向window
function foo () {
console.log(this); //window
console.log(this.a);
}
var a = 12;
foo(); //12
思考
var a = 12;
function test() {
this.a = 13; //重新付了一个值 a=13
}
test();
console.log
原创
2021-03-19 08:05:38 ·
256 阅读 ·
2 评论