What do you want to save?
Add Code snippet
New code examples
-
Javascript 2021-10-01 05:58:02
trailing comma javascript
Trailing commas (sometimes called "final commas") can be useful when adding new elements, parameters, or properties to JavaScript code. If you want to add a new property, you can simply add a new line without modifying the previously last line i... Add solution -
Other 2021-09-28 11:15:02
max element in array
// For large data, it's better to use reduce. Supose arr has a large data in this case: const arr = [1, 5, 3, 5, 2]; const max = arr.reduce((a, b) => { return Math.max(a, b) }); // For arrays with relatively few elements you can use apply: const max ... Add solution -
Other 2021-09-27 12:26:04
clear array vba
'In VBA to reset a dynamic array of Longs or Doubles to all zeros, the simplest way 'is to use the Redim() function. It's also extremely fast, roughly four times 'faster than iterating over the array to set each element. Sub Test_ArrayZeroing() Dim ... Add solution -
Java 2021-09-26 10:59:05
how to loop through an array
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 -
Javascript 2021-09-25 09:29:03
loop through javascript array
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 -
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 -
TypeScript 2021-09-17 02:11:02
Javascript:
/* Spread syntax ( ex. ...arrayName) allows an iterable such as an array expression or string to be expanded in places where zero or more arguments (for function calls) elements (for array literals) are expected, or an object expression to be expanded ... Add solution -
Javascript 2021-09-15 05:13:02
how to find max number in array javascript
// For large data, it's better to use reduce. Supose arr has a large data in this case: const arr = [1, 5, 3, 5, 2]; const max = arr.reduce((a, b) => { return Math.max(a, b) }); // For arrays with relatively few elements you can use apply: const max ... Add solution -
Javascript 2021-09-09 22:41:02
find mode js
//Everyone was sharing complex answers. I'm just gonna put my simple-ish code here //It suuports multiple values of same frequency //If u want the first value and not multiple in case of multiple modes just add [0] after pop() function function checkMostF... Add solution -
Javascript 2021-09-07 18:14:04
iterate over array javascript
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