What do you want to save?
Add Code snippet
New code examples
-
Javascript 2021-09-26 15:43:02
javascript remove duplicate in two arrays
// 1. filter() function removeDuplicates(array) { return array.filter((a, b) => array.indexOf(a) === b) }; // 2. forEach() function removeDuplicates(array) { let x = {}; array.forEach(function(i) { if(!x[i]) { x[i] = true } }) r... Add solution -
Javascript 2021-09-19 19:29:02
how to give id dynamically in javascript
//Here the delete button gets a unique ID everytime, the ID is the array index of the element. array.forEach(function (element, index) { display = display + `<tr> <th scope="row">${index + 1}</th... Add solution -
Javascript 2021-09-15 23:03:02
iterate over array of objects javascript
// Just loop through an array const myArray = [{x:100}, {x:200}, {x:300}]; myArray.forEach((element, index, array) => { console.log(element.x); // 100, 200, 300 console.log(index); // 0, 1, 2 console.log(array); // same myArray object 3 t... Add solution -
Javascript 2021-09-15 07:51:04
how to iterate array in javascript
let array = ['Item 1', 'Item 2', 'Item 3']; // Here's 4 different ways for (let index = 0; index < array.length; index++) { console.log(array[index]); } for (let index in array) { console.log(array[index]); } for (let value of array) { console... Add solution