🔸property name
string or symbol.
JS ⟩ values ⟩ object ⟩ property ⟩ name
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
:
must be an identifier❗
can be a reserved word❗
Last updated
Was this helpful?