var name和window.name [英] var name and window.name

查看:137
本文介绍了var name和window.name的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我定义一个名为 name 的JavaScript全局变量,是否会隐藏window.name属性?

If I define a JavaScript global variable called name, does that hide the window.name property?

我在Facebook JavaScript身份验证API的上下文中问这个问题,因为我发现拥有该名称的全局会破坏它,而且因为我看到 window.name 是在他们的代码中使用。

I ask this in the context of the Facebook JavaScript authentication API, since I noticed that having a global of that name would break it, and also since I see that window.name is used in their code.

推荐答案

如果 name 是一个全局变量,那么 name window.name 是等价的。

If name is a global variable, then name and window.name are equivalent.

全局变量和函数是全局对象的成员。在浏览器中,全局对象包含一个窗口成员,其值是全局对象。

Global variables and functions are members of the global object. In browsers, the global object contains a window member whose value is the global object.

这篇关于var name和window.name的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆