<script> //this指向的是最终调用它的那个对象 //this指向的是window function aa(){ var str = ‘jack‘; console.log(this.str); //undefined console.log(this); //window } window.aa(); //this指向的是bb var bb = { str : ‘jack‘, show : function(){ console.log(this.str); //jack } } window.bb.show(); </script>
时间: 2024-10-27 12:35:19