简体   繁体   English

在 ECMAScript 规范中我可以找到为什么 {}?== {} 的原因?

[英]Where in the ECMAScript specification can I find the reason about why {} !== {}?

In JavaScript We all know that {} !== {} - they are different objects allocated on heap.在 JavaScript 我们都知道{} !== {} - 它们是在堆上分配的不同对象。 But I was trying to find the reason at the language specification level.但我试图在语言规范级别找到原因。

at https://tc39.es/ecma262/#sec-samevaluenonnumeric it sayshttps://tc39.es/ecma262/#sec-samevaluenonnumeric它说

  1. If x and y are the same Object value, return true.如果 x 和 y 是相同的 Object 值,则返回 true。 Otherwise, return false.否则,返回假。

But it is unclear to me how the spec defines exactly when two objects are considered to have the same Object value.但我不清楚规范如何准确定义两个对象何时被认为具有相同的 Object 值。 Like {} and {} clearly do not have the same value but how exactly is it defined in the spec?{}{}显然没有相同的值,但它在规范中究竟是如何定义的?

{} in this context is an ObjectLiteral , when the runtime evaluation encounters such an ObjectLiteral it calls OrdinaryObjectCreate which itself calls MakeBasicObject which does return a new object. {}在这种情况下是一个ObjectLiteral ,当运行时评估遇到这样的 ObjectLiteral时,它会调用OrdinaryObjectCreate ,后者本身会调用MakeBasicObject ,后者确实返回一个的 object。

So two ObjectLiterals can't be SameObject.所以两个 ObjectLiterals 不能是 SameObject。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 ECMAScript:在哪里可以找到有关let / const变量可访问性的规范 - ECMAScript: Where can we find specification about accessibility of let/const variables 找不到 ECMAScript 在哪里提到了关于 scope 链 - Can't find where ECMAScript mentioned the about scope chain 在创建新词法环境时,我们可以在ECMAScript规范中的哪里找到确切的位置? - Where in the ECMAScript specification can we find exactly when new Lexical Environments are created? 在哪里可以找到具有ECMAScript 5功能的参考表? - Where can I find a reference sheet with ECMAScript 5 functions? 有人可以解释一下 ECMAScript 规范中提到运算符优先级和运算符关联性的地方吗 - can someone explain me where in the ECMAScript specification operator precedence and operator associativity is mentioned 如何在ECMAScript规范中解析此语法? - How do I parse this syntax in the ECMAScript specification? 我可以在当前浏览器中运行基于 ECMAScript 规范的语言,如 JScript 或 ActionScript 吗? - Can I run a language based on the ECMAScript specification like JScript or ActionScript in current browsers? setTimeout():如果没有在EcmaScript规范中定义,我在哪里可以了解它是如何工作的? - setTimeout(): If not defined in EcmaScript spec, where can I learn how it works? 我在哪里可以学习ECMAScript标准中尚未包含的JavaScript功能? - Where can I learn JavaScript features not yet included in ECMAScript standard? 在哪里可以找到有关JavaScript术语的更多信息? - Where can I find more information about JavaScript terms?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM