Appearance
keys() function
Returns an iterator of keys.
Supports plain objects, Map, and Set: - For objects: returns own enumerable string keyed property names - For Map: returns keys - For Set: returns values (Set keys are the same as values)
Signature:
typescript
declare function keys<T extends Map<any, any> | Set<any> | Record<Key, any>>(obj: T): KeysResult<T>;Example
ts
[...keys({ a: 1, b: "2", c: true })]
// ["a", "b", "c"]
[...keys(new Map([["a", 1], ["b", 2]]))]
// ["a", "b"]
[...keys(new Set([1, 2, 3]))]
// [1, 2, 3]