标签: javascript
var a = 'a'; var anotherA = 'a';
即使JS在true或a == anotherA时返回a === anotherA,两个变量实际上是否指向内存中的相同位置?
true
a == anotherA
a === anotherA
答案 0 :(得分:1)
它们的价值相等,但无法保证它们指向同一块内存。
答案 1 :(得分:0)
它们不存储在相同的内存地址中,因为每个变量都在JS中创建而没有引用点的新内存地址。 在这里,你只比较价值。为了比较价值,您实际上遵循ECMA-262
http://www.ecma-international.org/ecma-262/5.1/#sec-11.9.3