Variables As Properties

When you declare a global JavaScript variable, what you are actually doing is defining a property of the global object . If you use var to declare the variable, the

当你声明一个全局变量,实际上,你是给全局对象定义了一个属性。如果你是用 var 声明的变量,

property that is created is nonconfigurable , which means that it cannot be deleted with the delete operator. We’ve already noted that if you’re not using strict mode

所创建的属性是不可配置的,也就是说不能用 delete 操作符 从全局对象中删除掉。在非严格模式下,

and you assign a value to an undeclared variable, JavaScript automatically creates a global variable for you.

给一个尚未声明的变量赋值,JS 会自动创建一个全局变量。

JavaScript global variables are properties of the global object, and this is mandated by the ECMAScript specification. There is no such requirement for local variables,

JS全局变量就是全局对象的属性,这是ECMAScript 规定的。局部变量虽然没有这样的规定,

but you can imagine local variables as the properties of an object associated with each function invocation. The ECMAScript 3 specification referred to this object as

但是局部变量是 函数调时创建的关联对象 的属性,ECMAScript 3 把这个 关联对象叫做 “call object”,

the“call object,” and the ECMAScript 5 specification calls it a “declarative environment record.” JavaScript allows us to refer to the global object with the this keyword,

而 ECMAScript 5  把这个关联对象叫做 “声明环境记录”。JS 允许我们通过  this 关键字 来应用全局对象,

but it does not give us any way to refer to the object in which local variables are stored. The precise nature of these objects that hold local variables is an

但是,没有任何办法去引用这个 调用时创建 的关联对象。实现这个关联对象具体细节,不用我们去关心,

implementation detail that need not concern us. The notion that these local variable objects exist, however, is an important one.

但是,重要的是,要知道有这样的一个关联对象存在。

JS -- Variables As Properties的更多相关文章

  1. [Vue] Use Vue.js Component Computed Properties

    You can add computed properties to a component to calculate a property on the fly. The benefit of th ...

  2. jquery.i18n.properties.js hacking

    /****************************************************************************** * jquery.i18n.proper ...

  3. 分别用Java和JS读取Properties文件内容

    项目中经常用到的配置文件,除了XML文件之外,还会用到Properties文件来存储一些信息,例如国际化的设置.jdbc连接信息的配置等.有时候也会把一些路径或者sql语句放到Properties中, ...

  4. JS -- The Scope Chain 作用域链

    The Scope Chain JavaScript is a lexically scoped language: the scope of a variable can be thought of ...

  5. 基于jQuery.i18n.properties实现前端网站语言多版本

    我是参考播客做了个demo:http://blog.csdn.net/aixiaoyang168/article/details/49336709 jQuery.i18n.properties采用.p ...

  6. 使用 pdf.js 查看发票时,显示不了台头和印章的解决办法

    系统中使用了 pdf.js 来查看 PDF 文件,发现在查看 电子发票时, 缺失了很多信息, 刚开始以为是 PDF.JS 的 BUG, 后来调试发现只需要在 IIS 里添加一个 bcmap 后缀的 m ...

  7. 纯js国际化(i18n)

    i18n,是internationalization单词的简写,中间18个字符略去,简称i18n,意图就是实现国际化,方便产品在不同的场景下使用 目标:可以点击切换语言或者ChangeLanguage ...

  8. 解决前端js、css缓存问题

    去js标签库查询jquery.i18n.properties.js这个js引用到页面上: 新建一个配置文件:用上面的那个js方法调取配置文件里的版本号给其他的js加上: 示例: <script ...

  9. A Study of WebRTC Security

    转自:http://webrtc-security.github.io/ A Study of WebRTC Security Abstract Web Real-Time Communication ...

随机推荐

  1. SQL分组查询

      把数据分成多个逻辑组,以便能对每个组的数据进行操作,对每个组进行聚集计算. 1.创建分组 分组是在SELECT语句的GROUP BY子句中建立的 例子:         SELECT vendId ...

  2. Android项目实战(三十四):蓝牙4.0 BLE 多设备连接

    最近项目有个需求,手机设备连接多个蓝牙4.0 设备 并获取这些设备的数据. 查询了很多资料终于实现,现进行总结. ------------------------------------------- ...

  3. SVG渐变

    前面的话 给SVG元素应用填充和描边,除了使用纯色外,还可以使用渐变.本文将详细介绍SVG渐变 线性渐变 有两种类型的渐变:线性渐变和径向渐变.必须给渐变内容指定一个id属性,否则文档内的其他元素不能 ...

  4. Microsoft .Net Remoting系列专题之三:Remoting事件处理全接触

    前言:在Remoting中处理事件其实并不复杂,但其中有些技巧需要你去挖掘出来.正是这些技巧,仿佛森严的壁垒,让许多人望而生畏,或者是不知所谓,最后放弃了事件在Remoting的使用.关于这个主题,在 ...

  5. eclipse如何把多个项目用不同的文件夹分隔开

    我们有时候用eclipse时,发现Project Explorer下有非常多的项目,如果大部分不用了还好,我们可以从eclipse上删掉,但是如果还经常会用到的话,删掉了,每次用的时候,还得再重新导入 ...

  6. mkyaffs2image制作根文件系统、使用NFS挂载虚拟机目录(2)

    1.制作根文件系统及nfs烧写 1.1 先解压文件系统,/wok/nfs_root 目录下是已经构造好的各种文件系统:① fs_mini.tar.bz2 是最小的根文件系统,里面的设备节点是事先建立好 ...

  7. 在STEP7 TIA PORTAL中,设置模块的地址和设备名(Device name)

    assign device name, ip address for PROFINET componet in TIA Portal 方法1: PLC --> online & diag ...

  8. SUSE Linux Enterprise 11 离线安装 DLIB python机器学习模块

    python机器学习模块安装 环境:SUSE Linux Enterprise 11 sp4  离线安装 说明:在安装dlib时依赖的基础 环境较多,先升级gcc,以适应c++ 11的使用:需要用到c ...

  9. grunt之filerev、usemin

    窃以为这两个插件是比较有用的,filerev是给js.css进行编码重命名,usemin修改html中被重命名的js.css文件的引用.另外说明下之前将concat.cssmin.uglify放在一篇 ...

  10. 六,ESP8266 TCP Client

    今天不知道是不是让我姐挺失望.......很多时候都不知道自己努力的方向对不对,,以后能不能带给家人最美好的期盼...... Init.lua 没啥改变,,就改了一下加载Client.lua gpio ...