isPropertyKey
Checks if a value is a valid property key: string, number, or symbol.
Available since v2.0.3
Import
Section titled “Import”Signature
Section titled “Signature”Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
value | unknown | The value to check |
Returns
Section titled “Returns”value is PropertyKey — true if value can be used as an object property key
Examples
Section titled “Examples”Detect valid property keys
Section titled “Detect valid property keys”Strings, numbers, and symbols are valid property keys.
Safe dynamic property access
Section titled “Safe dynamic property access”Use as a guard before indexing an object with an unknown key.
