Skip to content

Latest commit

 

History

History
34 lines (22 loc) · 869 Bytes

result.md

File metadata and controls

34 lines (22 loc) · 869 Bytes

objects.result

result(object, path, [defaultValue])

Result, creates an array of values corresponding to paths of the object. If value is a function, returns result of calling function

Arguments

  1. object (object): input object
  2. path (Array|string): string or an array of strings describing paths to be returned from an object
  3. [defaultValue] (*): value returned when path resolves undefined

Returns

(*): value found by object paths in object, or returns defaultValue if provided and return would otherwise be undefined

Example

const obj = { front: [1, 3, 5], back: [() => 15, () => 19] };
console.log(objects.result(obj, 'back[1]'));
> 19