0

The behavior I expect:

const arr = [{id: 1, value: "45"},{id: 2 , value: "34"}]  
const newObject = {id: 1, value: "22"}

Output: [{id: 1, value: "22"},{id: 2 , value: "34"}]
  • [Duplicate](//google.com/search?q=site%3Astackoverflow.com+js+update+object+in+array+by+id) of [Replacing objects in array](/q/37585309/4642212). Familiarize yourself with [how to access and process nested objects, arrays or JSON](/q/11922383/4642212) and use the available static and instance methods of [`Array`](//developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array#Static_methods). – Sebastian Simon Sep 13 '21 at 05:59
  • find index then update its value `arr.findIndex(item => newObject.id === item.id)` – ahsan Sep 13 '21 at 06:03

0 Answers0