1//Initailize array of objects.
2let myArray = [
3 {id: 0, name: "Jhon"},
4 {id: 1, name: "Sara"},
5 {id: 2, name: "Domnic"},
6 {id: 3, name: "Bravo"}
7],
8
9//Find index of specific object using findIndex method.
10objIndex = myArray.findIndex((obj => obj.id == 1));
11
12//Log object to Console.
13console.log("Before update: ", myArray[objIndex])
14
15//Update object's name property.
16myArray[objIndex].name = "Laila"
17
18//Log object to console again.
19console.log("After update: ", myArray[objIndex])
1let myArray = [
2 {id: 0, name: "Jhon"},
3 {id: 1, name: "Sara"},
4 {id: 2, name: "Domnic"},
5 {id: 3, name: "Bravo"}
6],
7
8//Find index of specific object using findIndex method.
9objIndex = myArray.findIndex((obj => obj.id == 1));
10
11//Log object to Console.
12console.log("Before update: ", myArray[objIndex])
13
14//Update object's name property.
15myArray[objIndex].name = "Laila"
16
17//Log object to console again.
18console.log("After update: ", myArray[objIndex])