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. PHP导出excle图片与文字

    try { //CI框架引入PHPExcel $this->load->library('PHPExcel'); $objPHPExcel = new PHPExcel(); //图片处理 ...

  2. JSP知识点大致介绍1

    解释:当jsp写好,运行服务器,还没有发出请求(写网址按Enter),Tomcat的work下是没有字节码文件的.当写网址:localhost:8888/xxxx/index.jsp按Enter,运行 ...

  3. ASP.Net Core Razor 页面路由

    在服务器端 Web 应用程序框架中,其中非常重要的设计是开发人员如何将URL与服务器上的资源进行匹配,以便正确的处理请求.最简单的方法是将 URL 映射到磁盘上的物理文件,在 Razor 页面框架中, ...

  4. 利用jmeter+JAVA对RPC的单接口(dubbo接口等)进行性能测试

    建立JAVA项目 建立maven项目,加入Jmeter所需要的JAR包依赖. POM.xml  加入如下: <dependency> <groupId>org.apache.j ...

  5. 散列表(拉链法与线性探测法)Java实现

    package practice; import java.security.Principal; import java.util.Scanner; import edu.princeton.cs. ...

  6. 如何解决xshell中无法输入中文的问题

    自从安上了xshell以后,用着那叫一个顺手,美中不足的就是一直无法输入中文.不过,既然学习IT,就要习惯英文嘛~直到--我遇到了脚本,写好一个脚本,必要的注释是少不了的,但是作为一个英文渣渣,我真的 ...

  7. 使用 LVS 实现负载均衡原理及安装配置详解

    负载均衡集群是 load balance 集群的简写,翻译成中文就是负载均衡集群.常用的负载均衡开源软件有nginx.lvs.haproxy,商业的硬件负载均衡设备F5.Netscale.这里主要是学 ...

  8. css样式实现立方体制作

    <!doctype html> <html> <head> <meta charset="utf-8"> <title> ...

  9. 团队作业8——第二次项目冲刺(Beta阶段)5.27

    1.当天站立式会议照片 会议内容: 本次会议为第七次会议 本次会议在陆大楼2楼召开,本次会议内容: ①:检查总结上次任务完成情况 ②:安排今天的分工 ③:对昨天的问题进行讨论 2. 每个人的工作 (有 ...

  10. 姑娘你大胆地往前走——答大二学生XCL之八问

    姑娘你大胆地往前走--答大二学生XCL之八问 以下问题的答案写给我家正在读大二的XCL. 写于 2017-9-13 晚 请问您是为什么选择了IT行业的? 与其说是我选择了行业,不如说是行业选择了我. ...