What do you want to save?
Add Code snippet
New code examples
-
Javascript 2021-11-09 13:28:14
how to update whole object in array using lodash
var arr = [{id: 1, name: "Person 1"}, {id:2, name:"Person 2"}]; // Find item index using _.findIndex (thanks @AJ Richardson for comment) var index = _.findIndex(arr, {id: 1}); // Replace item at index using native splice arr.splice(i... Add solution -
Javascript 2021-11-05 11:27:11
var categories_arr = this.state.categories; for (var i=0;i<categories_arr.length;i++) { if(categories_arr[i].id==category_id) { categories_arr.splice(i,1); this.setState({categories:categories_arr}); } }
onDelete(category_id) { axios.delete('http://127.0.0.1:8000/category/delete/'+category_id) .then(response =>{ var categories_arr = this.state.categories; for (var i=0;i<categories_arr... Add solution -
Javascript 2021-09-06 20:26:03
delete vs splice javascript
/* Delete: removes the object from the element in the array, the length of the array won't change. Splice: removes the object and shortens the array. */ // Using delete arr = ['a', 'b', 'c', 'd']; delete arr[0]; console.log(arr); // [empty, "b&quo... Add solution -
Javascript 2021-09-03 22:07:02
remove item at index in array javascript
// remove element at certain index without changing original let arr = [0,1,2,3,4,5] let newArr = [...arr] newArr.splice(1,1)//remove 1 element from index 1 console.log(arr) // [0,1,2,3,4,5] console.log(newArr)// [0,2,3,4,5] Add solution
Best helpers
The Jester
+5
Dalum
+5
Zack Marotta
+5
Key_asdfg
+5
Hi-yi
+5
Travis Webb
+5
Tim Tully
+5
Rodica MARIN
+5
Irini
+5
Zhak Maarli
+5
Giorgio_B
+5
Miky
+5
Nitesh
+5
Dani Pop
+5
Moji Moji
+5
Steve Bowman
+5
Sunrise Moon
+5
Nichole Deas
+5