Joao Rodrigues wrote:
> JRough wrote:
>> me (JRough change)
>>
>> 4:31 PM (less than a minute ago)
>>
>>
>> var a={}; a["b"]=123, a["c"]=456; console.log(a["b"]); undefined
>>
>> var a={}; a.b=123, a.c=456; console.log(a.b); undefined
>>
>>
>> Why is this object literal not defined? If it is because it was
>> stringified how to make it an object again so you get the value?
>> tnx,
>
> This object literal is being defined accordingly.
The (referred) _object_ is being defined as intended.
An object *literal* (standard term: “object _initializer_”; it is actually
_not_ listed under “11.8 Literals”[1]) is an *expression* that begins with
“{”, ends with “}”, and can be produced by the /ObjectLiteral/ production
of the ECMAScript grammar:
<
http://www.ecma-international.org/ecma-262/8.0/#prod-ObjectLiteral>
[Yes, *8.0*: “ECMAScript® 2017 Language Specification
(ECMA-262, 8th edition, June 2017”.
^^^^^^^^^
Harder to keep track of this nowadays. Given the recent releases,
I just tried the greater revision number, and there it was.]
For example, “{}” is an object initializer; so are “{foo: "bar"}” and
“{"baz": 42}”.
An object is a conceptual entity only: it exists only abstractly, and in
memory only inasfar as that memory is reserved to store therein the bindings
that refer to the object, and the names and the values of its properties.
By contrast, an object *initializer* is an element of the syntax of these
programming languages.
<
http://www.ecma-international.org/ecma-262/8.0/#sec-terms-and-definitions-object>
__________
[1] <
http://www.ecma-international.org/ecma-262/8.0/#sec-ecmascript-language-lexical-grammar-literals>
--
PointedEars
FAQ: <
http://PointedEars.de/faq> | <
http://PointedEars.de/es-matrix>
<
https://github.com/PointedEars> | <
http://PointedEars.de/wsvn/>
Twitter: @PointedEars2 | Please do not cc me./Bitte keine Kopien per E-Mail.