这里有答案,但还是不能理解为什么constructor不能判断数组,后面谷歌了一下终于找到了。
http://blog.csdn.net/lee_magnum/article/details/11555981
答案:
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Document</title> </head> <body> <iframe id="fr1"></iframe> <script> window.onload = function () { var iframe = document.getElementById('fr1'); var iwindow = iframe.contentWindow; var idoc = iwindow.document; //获取iframe里面的数组 var xArray = iwindow.Array; //当去当前页面的数组 var arr = []; console.log(xArray.constructor == Array);//false console.log(arr.constructor == Array);//true } </script> </body> </html>
参考资料:
http://blog.csdn.net/lee_magnum/article/details/11555981
https://segmentfault.com/a/1190000004502619