What do you want to save?
Add Code snippet
New code examples
-
Javascript 2021-09-17 14:40:01
spread operator javascript
// spread operators can be used for arrays or objects // cloning to prevent mutation. let numList = [1,2,3]; let numListClone = [...numList]; // [1, 2, 3] // spread operator for destructuring. let animal = { name: 'dog', color: 'brown', age: 7 }; ... Add solution -
Javascript 2021-09-15 06:41:03
javascript fisher yates shuffle mdn
function shuffle(array) { for (let i = array.length - 1; i > 0; i--) { let j = Math.floor(Math.random() * (i + 1)); // random index from 0 to i // swap elements array[i] and array[j] // we use "destructuring assignment" syntax ... Add solution -
Javascript 2021-09-14 09:33:02
how to get first and last element of array in javascript
The rest parameter can only use at the end not anywhere else in the destructuring so it won't work as you expected. Instead, you can destructor certain properties(an array is also an object in JS), for example, 0 for first and index of the last element f... Add solution