Skip to content

Latest commit

 

History

History
34 lines (22 loc) · 788 Bytes

get.md

File metadata and controls

34 lines (22 loc) · 788 Bytes

objects.get

get(object, path, [defaultValue])

Get, creates an array of values corresponding to paths of the object

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 result = objects.get({ front: [1, 3, 5], back: [37, 39] });
console.log(result, 'back[1]');
> 39