您的位置:首页 > 其它

理清浏览器Window对象&window对象&this对象

2016-07-17 16:22 232 查看
<!DOCTYPE html>
<html>
<head>
<title>chrome</title>
</head>
<body>
<script type="text/javascript">

console.log(Window);      //构造函数Window,由浏览器内核原生代码实现 [native code]

try{
ww = new Window();       //Window对象无法直接在JS脚本中实例化
}
catch(error){
console.log(error);     // TypeError (native)
}

console.log(this.constructor == Window);   //true,浏览器this对象,指向一个Window对象
console.log(this);       //瞅瞅Window对象提供了哪些属性和方法供开发者使用

console.log(window == this);     //true
console.log(this.window == this);     //true,window即this.window与this指向同一个Window对象
</script>
</body>
</html>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: