Why are myarray instanceof Array and myarray.constructor === Array both false when myarray is in a frame?

后端 未结 2 1353
醉酒成梦
醉酒成梦 2020-12-10 06:35

So the following code alerts false twice:

window.onload = function(){
                    alert(window.myframe.myarray instanceof Array);
                            


        
2条回答
  •  抹茶落季
    2020-12-10 06:57

    The two windows each create their own global script environment.

    The Array constructor of one is not the same object as the other.

    var win2=window.myframe;
    alert(win2.myarray instanceof win2.Array); returns true
    

提交回复
热议问题