get(object, path) ⇒ any

Gets value from an object by path

Returns: any - found value Params

  • object Object | Array.<any> - object to update
  • path string | Array.<string> - path to be updated (array of items or dot-separated string can be provided)

Description

get() is more like helper, not an operation since it doesn't perform any update, just returns value found by path.

import { get } from 'immutable-object-update';

const state = {
    a: {
        a1: 1,
        a2: 2
    },
    b: {
        b1: 3,
        b2: 4
    }
};

const value = get(state, [ 'b', 'b1' ]); // returns 3

// or

const updated = get(state, 'b.b1', 5); // returns 3

results matching ""

    No results matching ""