Answers for "javascript find object in array and replace it"

0

find and replace value in array of objects javascript

let arr = [
  {
    "enabled": true,
    "deviceID": "eI2K-6iUvVw:APA",
  },
  {
    "enabled": true,
    "deviceID": "e_Fhn7sWzXE:APA",
  },
  {
    "enabled": true,
    "deviceID": "e65K-6RRvVw:APA",
  },
];

const id = 'eI2K-6iUvVw:APA';

arr.find(v => v.deviceID === id).enabled = false;

console.log(arr);
Posted by: Guest on December-15-2020
-1

javascript find object in array and replace it

const updatedData = originalData.map(x => (x.id === id ? { ...x, updatedField: 1 } : x));
Posted by: Guest on December-11-2020

Code answers related to "javascript find object in array and replace it"

Code answers related to "Javascript"

Browse Popular Code Answers by Language