EBIA

Tag: lodash

Lodash related Examples

map

Creates an array of values by running each element in collection thru iteratee.

_.map(obj, (v, k) => ({key: k, value: v}))

mapValues & keyBy

mapValues Creates an object with the same keys as object and values generated by running each own enumerable string keyed property of object thru iteratee.

keyBy Creates an object composed of keys generated from the results of running each element of collection thru iteratee. The corresponding value of each key is the last element responsible for generating the key.

var result = _.mapValues(_.keyBy(input, 'key'), 'value');

JSON Related

Extend JSON Arrays with lodash

lodash.each($scope.myDataFromREST, function(item) {
    lodash.extend(item, {
        "edit": false,
        "some": {
            "foo": "bar"
        }
    });
});

Copyright © 2020 EBIA

Theme by Anders NorenUp ↑