Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

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);
Comment

javascript find object in array and replace it

 const updatedData = originalData.map(x => (x.id === id ? { ...x, updatedField: 1 } : x));
Comment

PREVIOUS NEXT
Code Example
Javascript :: jquery add div 
Javascript :: jquery onload function for div 
Javascript :: js get last array element 
Javascript :: datatable order number 
Javascript :: append child at the top 
Javascript :: express js static files 
Javascript :: bootstrap 4 navbar-collapse not working angular 
Javascript :: React JS CDN Links 
Javascript :: firebase read data javascript 
Javascript :: js date enlever jour 
Javascript :: javascript element edit text 
Javascript :: boolean object js 
Javascript :: js get form inputs 
Javascript :: js largest number in array 
Javascript :: particles js is not full screen 
Javascript :: electron check if file exists 
Javascript :: get params from route vuejs 
Javascript :: javascript radio button value if checked 
Javascript :: javascript to remove few items from array 
Javascript :: nodejs path 
Javascript :: how to sort array without using sort method in javascript 
Javascript :: not in array js 
Javascript :: binary search algorithm in javascript 
Javascript :: angular ngfor counter 
Javascript :: jquery select dropdown option 
Javascript :: download file from api vue 
Javascript :: How to use body-parser package in using npm 
Javascript :: aws amplify get JWT TOKEN 
Javascript :: how to sort json objects 
Javascript :: axios Request body larger than maxBodyLength limit 
ADD CONTENT
Topic
Content
Source link
Name
5+4 =