Is There a Function in Lodash to Replace Matched Item

is there a function in lodash to replace matched item

In your case all you need to do is to find object in array and use Array.prototype.splice() method, read more details here:

var arr = [{id: 1, name: "Person 1"}, {id:2, name:"Person 2"}];
// Find item index using _.findIndex (thanks @AJ Richardson for comment)var index = _.findIndex(arr, {id: 1});
// Replace item at index using native splicearr.splice(index, 1, {id: 100, name: 'New object.'});
// "console.log" resultdocument.write(JSON.stringify( arr ));
<script src="//"></script>

Lodash: replace value in array of objects

You can use like below

const dataTwo =, item => ({...item, created_at: moment(item.created_at).format('MMM') }))

Plain JS or Lodash - replace object values with values from other object

With lodash you could do something like this with _.merge, _.pick and _.keys:

let first = {   a: 'John',   b: 22,   c: 'example'}, second = {   b: 55,   d: 'demo'}
let result = _.merge(first, _.pick(second, _.keys(first)))
<script src=""></script>

How to replace an object in object array in javascript (lodash)

you can do it with _.unionBy

var res = _.unionBy([obj], arr, 'id');

but check a note at this comment

How to merge objects with Lodash, but replace arrays values?

Use _.mergeWith(), and if the 2nd value is an array, return it. If not return undefined, and let merge handle it: