JavaScript: Difference between revisions

375 bytes added ,  17 December 2019
No edit summary
Line 3: Line 3:


==Usage==
==Usage==
===Arrays===
<syntaxhighlight lang="javascript">
let arr = [1,2,3];
// Map
arr.map(x => x > 2); // [false, false, true]
// Reduce or Fold
// Note that if you do not provide an initial accumulator,
// then the first element will be your accumulator
// I.e. the first call to your function will be (arr[0], arr[1])
arr.reduce((acc, x) => acc + x, 0); //6
</syntaxhighlight>
===Canvas===
===Canvas===
===Video===
===Video===