What do you want to save?
Add Code snippet
New code examples
-
TypeScript 2021-10-12 07:48:07
react setstate in hooks to array of objects value
const[array,setArray]= useState([ {id: 1, value: "a string", othervalue: ""}, {id: 2, value: "another string", othervalue: ""}, {id: 3, value: "a string", othervalue: ""},... Add solution -
Javascript 2021-09-27 05:26:04
update object in array if id exists else append javascript
function upsert(array, item) { // (1) const i = array.findIndex(_item => _item.id === item.id); if (i > -1) array[i] = item; // (2) else array.push(item); } const array = [ {id: 0, name: 'Apple', description: 'fruit'}, {id: 1, name: 'Bana... Add solution -
Javascript 2021-09-11 04:41:02
javascript array patch object in array
//Initailize array of objects. let myArray = [ {id: 0, name: "Jhon"}, {id: 1, name: "Sara"}, {id: 2, name: "Domnic"}, {id: 3, name: "Bravo"} ], //Find index of specific object using findIndex method. ... Add solution -
Javascript 2021-09-08 09:27:04
javascript find object array
myArray.findIndex(x => x.id === '45'); Add solution