1let arr = [
2 { name:"string 1", value:"this", other: "that" },
3 { name:"string 2", value:"this", other: "that" }
4];
5
6let obj = arr.find(o => o.name === 'string 1');
7
8console.log(obj);
1let arr = [
2 { name:"string 1", value:"this", other: "that" },
3 { name:"string 2", value:"this", other: "that" }
4];
5
6let obj = arr.find((o, i) => {
7 if (o.name === 'string 1') {
8 arr[i] = { name: 'new string', value: 'this', other: 'that' };
9 return true; // stop searching
10 }
11});
12
13console.log(arr);