What do you want to save?
Add Code snippet
New code examples
-
Javascript 2021-11-19 15:45:21
spread operator javascript object
// 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 -
Other 2021-11-18 04:40:28
iterative segment tree codeforces
const int N = 1e5; // limit for array size int n; // array size int t[2 * N]; void build() { // build the tree for (int i = n - 1; i > 0; --i) t[i] = t[i<<1] + t[i<<1|1]; } void modify(int p, int value) { // set value at position p ... Add solution -
Javascript 2021-11-13 11:44:18
loop through an 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 -
Javascript 2021-11-13 09:05:20
loop through 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 -
Javascript 2021-11-12 18:05:16
javascript through 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-11-11 06:12:16
javascript min max 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 -
Javascript 2021-11-10 23:04:21
array spread operator in 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-11-06 08:40:21
javascript get array min and max
// 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-11-05 06:37:07
c# is json valid
private static bool IsValidJson(string strInput) { if (string.IsNullOrWhiteSpace(strInput)) { return false;} strInput = strInput.Trim(); if ((strInput.StartsWith("{") && strInput.EndsWith("}")) || //For object ... Add solution
Best helpers
Ranking is empty