js中的this指代全局对象

在js中使用如下方式定义的this则代表window对象



function methodFun(){

        this.name ="hello";

}


merhodFun();


则此时可以直接使用alert(name)调用相当于  window.name

猜你喜欢

转载自blog.csdn.net/u011922760/article/details/73358518