๐Ÿ”ธproperty name

string or symbol.

JS โŸฉ values โŸฉ object โŸฉ property โŸฉ name

(String / Symbol)

a property name may be any String / Symbol.

(any other value is coerced to String.)

// defining properties
{
    age  : 26,                    // normal string property name
    1    : '1 is OK',              // normal string property name
    const: 'reserved word is OK',  // reserved word as property name
    "full name": "John Doe",       // string as property name
}

// accessing properties
obj . prop    // by identifier
obj [ prop ]  // by String / Symbol.

in dot notation (.) obj.prop syntax, the prop๏ผš

Last updated