1//Initailize array of objects.
2let myArray = [ {id: 0, name: "Jhon"}, {id: 1, name: "Sara"}, {id: 2, name: "Domnic"}, {id: 3, name: "Bravo"}],
3
4//Find index of specific object using findIndex method.
5objIndex = myArray.findIndex((obj => obj.id == 1));
6
7//Log object to Console.
8console.log("Before update: ", myArray[objIndex])
9
10//Update object's name property.
11myArray[objIndex].name = "Laila"
12
13//Log object to console again.
14console.log("After update: ", myArray[objIndex])
1const newProjects = projects.map(p =>
2 p.value === 'jquery-ui'
3 ? { ...p, desc: 'new description' }
4 : p
5);
6
1var projects = [ { value: "jquery", label: "jQuery", desc: "the write less, do more, JavaScript library", icon: "jquery_32x32.png" }, { value: "jquery-ui", label: "jQuery UI", desc: "the official user interface library for jQuery", icon: "jqueryui_32x32.png" }, { value: "sizzlejs", label: "Sizzle JS", desc: "a pure-JavaScript CSS selector engine", icon: "sizzlejs_32x32.png" }];
2
1var projects = {
2 jqueryUi : {
3 value: 'lol1',
4 desc: 'lol2'
5 }
6};
7
8projects.jqueryUi.desc = 'new string';
9