What do you want to save?
Add Code snippet
New code examples
-
Javascript 2022-02-28 07:35:02
javascript array clear
let aray = [1,2,3,4,5,6,7,8,9,10]; //as with most coding there are several ways you can do anything //see whichever works best for your scenario //set the array to equal a blank array array = []; //set the array's length to 0 array.length = 0; //using... Add solution -
Javascript 2022-02-19 10:35:24
array map
const myArray = ['Sam', 'Alice', 'Nick', 'Matt']; // Appends text to each element of the array const newArray = myArray.map(name => { return 'My name is ' + name; }); console.log(newArray); // ['My name is Sam', 'My Name is Alice', ...] // Appends ... Add solution -
Javascript 2022-02-18 01:25:12
map a keys from an array in a separate arraylist javascript
const myUsers = [ { name: 'shark', likes: 'ocean' }, { name: 'turtle', likes: 'pond' }, { name: 'otter', likes: 'fish biscuits' } ] const usersByLikes = myUsers.map(item => { const container = {}; container[item.name] = item.likes... Add solution -
Javascript 2022-02-16 18:35:08
loop through an array in js
var data = [1, 2, 3, 4, 5, 6]; // traditional for loop for(let i=0; i<=data.length; i++) { console.log(data[i]) // 1 2 3 4 5 6 } // using for...of for(let i of data) { console.log(i) // 1 2 3 4 5 6 } // using for...in for(let i in data) { con... Add solution