jjzjj

strictFunction

全部标签

javascript - 在全局范围调用 Object.prototype 方法

此代码会引发错误。try{alert(hasOwnProperty('window'));}catch(e){alert(e);//TypeError:can'tconvertundefinedtoobject}但是这段代码不会抛出错误。try{alert(this.hasOwnProperty('window'));//true(ifonbrowser)}catch(e){//throughcatchblockalert(e);}LiveExample|LiveSource据我所知,如果this是全局对象,则func(arg)等于this.func(arg)。为什么会发生这样的事情?