<!-- this 指向调用函数的对象 -->
<script>
var name = 'Jenny Global';
var person = {
name : 'Jenny',
details : {
name : 'Jenny details',
print : function(){
console.log('this = ',this);
return this.name;
}
},
print:function(){
console.log('this = ',this);
return this.name;
}
}
console.log(person.details.print());
console.log(person.print());
var name1 = person.print;
var name2 = person.details;
console.log(name1());
console.log(name2.print());
</script>
this指向调用函数的对象
最新推荐文章于 2022-07-21 21:03:05 发布