🔸property name

string or symbol.

JSvaluesobjectproperty ⟩ 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