to-property-key-x
v3.1.2 toPropertyKey abstract javascript nodejs browser
to-property-key-x
Converts argument to a value that can be used as a property key.
Version: 2.0.2
Author: Xotic750 [email protected]
License: MIT
Copyright: Xotic750
module.exports(argument)
⇒ string
| symbol
⏏
This method Converts argument to a value that can be used as a property key.
Kind: Exported function
Returns: string
| symbol
- The converted argument.
Throws:
TypeError
If argument is not a symbol and is not coercible to a string.
Param | Type | Description |
---|---|---|
argument | * |
The argument to onvert to a property key. |
Example
import toPropertyKey from 'to-property-key-x';
console.log(toPropertyKey()); // 'undefined'
console.log(toPropertyKey(1)); // '1'
console.log(toPropertyKey(true)); // 'true'
const symbol = Symbol('a');
console.log(toPropertyKey(symbol)); // symbol
toPropertyKey(Object.create(null)); // TypeError
npm i to-property-key-x
Metadata
- MIT
- >=8.11.4
- Graham Fairweather
- released 8/28/2019