xdash API Reference / filterKeys
Function: filterKeys()
filterKeys<
T>(obj,fn):Record<string,T>
Defined in: src/object.ts:106
Filters an object by its keys.
Type Parameters
T
T
Parameters
obj
Record<string, T>
object to filter
fn
(key, value) => unknown
callback to filter the object
Returns
Record<string, T>
the filtered object
Example
ts
filterKeys({ a: 1, b: 2 }, key => key === 'a') // returns { a: 1 }
filterKeys({ a: 'hello', b: 'world' }, key => key === 'a') // returns { a: 'hello' }