JS -- Variables As Properties
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的更多相关文章
- [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 ...
- jquery.i18n.properties.js hacking
/****************************************************************************** * jquery.i18n.proper ...
- 分别用Java和JS读取Properties文件内容
项目中经常用到的配置文件,除了XML文件之外,还会用到Properties文件来存储一些信息,例如国际化的设置.jdbc连接信息的配置等.有时候也会把一些路径或者sql语句放到Properties中, ...
- JS -- The Scope Chain 作用域链
The Scope Chain JavaScript is a lexically scoped language: the scope of a variable can be thought of ...
- 基于jQuery.i18n.properties实现前端网站语言多版本
我是参考播客做了个demo:http://blog.csdn.net/aixiaoyang168/article/details/49336709 jQuery.i18n.properties采用.p ...
- 使用 pdf.js 查看发票时,显示不了台头和印章的解决办法
系统中使用了 pdf.js 来查看 PDF 文件,发现在查看 电子发票时, 缺失了很多信息, 刚开始以为是 PDF.JS 的 BUG, 后来调试发现只需要在 IIS 里添加一个 bcmap 后缀的 m ...
- 纯js国际化(i18n)
i18n,是internationalization单词的简写,中间18个字符略去,简称i18n,意图就是实现国际化,方便产品在不同的场景下使用 目标:可以点击切换语言或者ChangeLanguage ...
- 解决前端js、css缓存问题
去js标签库查询jquery.i18n.properties.js这个js引用到页面上: 新建一个配置文件:用上面的那个js方法调取配置文件里的版本号给其他的js加上: 示例: <script ...
- A Study of WebRTC Security
转自:http://webrtc-security.github.io/ A Study of WebRTC Security Abstract Web Real-Time Communication ...
随机推荐
- Web初学-Web应用细节
一.web应用程序简介 WEB应用程序指供浏览器访问的程序,通常也简称为web应用. 一个web应用由多个静态web资源和动态web资源组成,如: html.css.js文件 Jsp文件.java程序 ...
- Javaweb项目碰到的问题- Access denied for user 'root'@'localhost' (using password: YES)
出现未给localhost root用户授权,主要是项目中存在的多个xxx.properties,其中用户名为root的password的值不完全相同导致的,使用eclipse的search 功能找到 ...
- RabbitMQ核心概念篇
RabbitMQ介绍 一.RabbitMQ使用场景 RabbitMQ他是一个消息中间件,说道消息中间件[最主要的作用:信息的缓冲区]还是的从应用场景来看下: 1.系统集成与分布式系统的设计 各种子系统 ...
- js中bind、call、apply函数的用法 (转载)
最近看了一篇不错的有关js的文章,转载过来收藏先!!! 最近一直在用 js 写游戏服务器,我也接触 js 时间不长,大学的时候用 js 做过一个 H3C 的 web 的项目,然后在腾讯实习的时候用 j ...
- 百行go代码构建p2p聊天室
百行go代码构建p2p聊天室 百行go代码构建p2p聊天室 1. 上手使用 2. whisper 原理 3. 源码解读 3.1 参数说明 3.1 连接主节点 3.2 我的标识 3.2 配置我的节点 3 ...
- 《个人-GIT使用方法》
使用GIT版本控制工具及基本使用方法(安装,新建,推送,拉取),托管平台的使用方法. Git 常用命令 git init here -- 创建本地仓库(repository),将会在文件夹下创建一个 ...
- CSS3四个自适应关键字——fill-available、max-content、min-content、fit-content
前面的话 一般地,有两种自适应:撑满空闲空间与收缩到内容尺寸.CSS3将这两种情况分别定义为'fill-availabel'和'fit-content'.除此之外 ,还新增了更细粒度的'min-con ...
- Spring定时任务quartz表达式
详见:http://blog.yemou.net/article/query/info/tytfjhfascvhzxcytp32 0 0 12 * * ?---------------在每天中午12: ...
- poj 1200字符串hash
题意:给出不同字符个数和子串长度,判断有多少个不同的子串 思路:字符串hash. 用字符串函数+map为什么会超时呢?? 代码: #include <iostream> #include ...
- MPLS LDP随堂笔记1
LDP 的使用原因(对于不同协议来说) LDP的四大功能 发现邻居 hello 5s 15s 224.0.0.2 发现邻居关系 R1 UDP 646端口 R2 UDP 646端口 此时形成邻居 建立邻 ...