Repository with examples used in my Medium article How to use Reduce in Javascript
- Clone this project.
- Install all dependencies by opening this project in terminal and running
yarn
or
npm install
- Launch already existing tests or write new/edit them according to your needs.
I'm using Jest
as a testing framework.
To launch tests, simply run
yarn test
or
npm run jest
- filter
- flat
- Object.fromEntries
- map
- every()
- some()
- find()
- findIndex()
- includes() - find with Boolean(result)
- lastIndexOf()
- indexOf()
- slice()
- toString()
- push()
- join() - NodeLists though
- reduceRight() - reverse the input?
- reverse()
- splice()
- copyWithin()
- fill()
- flatMap()
- at()
-
entries() - will have to create an iterator
-
keys() - iterator
-
values()
-
Array.from() - sets
-
pop() - two operations - might be a freebie but needs time to think
-
shift() - as above
-
unshift() - aa + a bit overkill to use reduce here
-
sort()
-
toLocaleString()
- toSource() - out of use
- forEach() - forEach is found in almost every language
- Array.isArray() - reduce is an Array.prototype method
- reduce() - :)
- concat()
- Array.of()