Skip to content

Latest commit

 

History

History
34 lines (22 loc) · 762 Bytes

findKey.md

File metadata and controls

34 lines (22 loc) · 762 Bytes

objects.findKey

findKey(object, [predicate=(x)], [thisArg])

FindKey returns the key of the first property value for which a supplied function returns true

Arguments

  1. object (object): input object
  2. [predicate=(x)] (function): function to test against object values
  3. [thisArg] (*): value of this in a function call

Returns

(string): string of the first object key whose value returns truthy against the function

Example

const result = Objects.findKey({ apple: 34, pear: 434, orange: 4 }, x => x > 100 );
console.log(result);
> 'pear'