- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
最近我读到有关 ES5 规范的内容,第 10 章 中有一个关于执行上下文 的混淆。更确切地说,混淆存在于 10.5[ https://ecma-international.org/ecma-262/5.1/#sec-10.5 ].
第10.5条Declaration Binding Instantiation,它解释了Execution Context的组件VariableEnvironment是如何生成的。我困惑的地方是item-5-iii:“如果 existingProp .[[Configurable]] 为真...”。
这样做的目的是什么,为什么在调用全局对象的 [[DefineOwnProperty]] 时 PropertyDescriptor.[[Value]] 未定义,如何用真实的 javascript 代码证明这一步?
或者这是一个错误?这里的[[Value]]应该是声明的函数对象吧?
最佳答案
当在顶层声明一个函数时,它会首先检查属性名称是否存在于全局对象上。如果该属性不存在,则:
c. Let funcAlreadyDeclared be the result of calling env’s HasBinding concrete method passing fn as the argument.
d. If funcAlreadyDeclared is false, call env’s CreateMutableBinding concrete method passing fn and configurableBindings as the arguments.
否则,它会进入您正在查看的 e.
部分:
e. Else if env is the environment record component of the global environment then: ...
因此,e.
中的任何地方,funcAlreadyDeclared
都必须是 true
- 属性是 已经定义,剩下的就是检查属性是否可变。 PropertyDescriptor.[[Value]]
必然会返回一个完整的属性描述符,因为在 e.
中,我们知道该属性确实存在;该 block 仅在 funcAlreadyDeclared
为 true
时运行。
在顶层,它检查属性是否可配置,如果是,则在全局对象上设置关联的属性。例如,顶层的 function foo(){}
将导致 window.foo
被定义,这部分检查 window.foo
可以定义。
具有 可配置
的 true
means :
true if and only if the type of this property descriptor may be changed and if the property may be deleted from the corresponding object.
例如,window.top
是不可配置的,所以 [[DefineOwnProperty]]
将不会运行:
console.log(Object.getOwnPropertyDescriptor(window, 'top'));
因此,尝试在顶层声明一个名为 top
的函数会抛出错误:
function top() {
}
关于javascript - 如何理解ECMA-262 5.1版中的条款10.5?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57107527/
我的文件示例: [ { username: 'userA', action: 'click', page: 'home' }, { username: 'u
在 AgdaIntro 中, View 部分解释了: ..that with doesn’t remember the connection between the with-term and the
似乎 In 子句在 Linq 3.0 (trunk) 中不能正常工作 我尝试了以下操作: var l = session.Query.Where(p => searchGroups.Contains(
我想在kibana中创建一个可视化效果,以显示不同数据的平均值。我已经创建了显示在日志中的字段,并且还执行了管理->索引模式->刷新。 现在,当我尝试以可视化方式创建图表时-> e.x(条形图)->汇
想象以下搜索词“棕狐”。 所有文档确实都有另一个字段,称为备用名称。 该字段有时包含诸如“动物”或“狐狸”之类的漂亮术语。有时它包含“不好的”(或人类可读的)术语,例如ED2314或1231-234-
我正在尝试使用 Z3 的 HORN 逻辑(set-logic HORN)对一些命令式程序进行编码,但在定义子句时遇到一些困难(使用 SMT2)。谁能告诉我在哪里可以找到有关 Z3 的此功能的良好文档来
我有一个办公室 ID 数组,该数组可能为空。如果 officeIdsToSelect 数组为空,我希望 EF 查询返回所有 记录,或者如果不为空,则仅返回匹配的记录。然而这: int[] office
我正在使用 ark 从 oracle 下载中下载 jdk7u51。 ark 'jdk' do url 'http://download.oracle.com/otn/java/jdk/7u51-
我正在处理一个项目(其他人的代码),其中一个方法被声明为抛出一堆它不可能抛出的已检查异常。 基本上,该方法如下所示: // Assume E1 extends Exception // Assume
所以,我想我理解级联文件系统的基本术语,但我似乎无法理解 MVC 的“层次结构”。谁能告诉我使用 HMVC 相对于 MVC 的优势以及它的基本预期功能吗? 感谢您的宝贵时间! 最佳答案 HMVC 更适
在C++ draft standard N3337节[expr.const.cast]/8 : The following rules define the process known as cast
我是一名优秀的程序员,十分优秀!