2, 10, 16];
const filterArray = array.filter(num => num > 5);
console.log(filterArray);
Why did they build this build-in method filter when you can just use a function that can just iterates numbers you can just select on the conditional line?
why did they create switch statements when you can have multiple if statements.
Yeah, the same goes for map and reduce as well… when you can just use a function and make whatever conditon you wanna put in in the conditional block.
But using these functions is much more powerful than interating. For example, you can chain multiple map, filter .. etc.
Why did they add numbers to JS when you can just invent your own numbers using church encoding (functions) or strings?
The cause and effect worldview vs Teleological worldview
filter was added because Brendan thought it was a good idea to add it
The ones who believe in Teleological worldview would ask, then why did God add Brenden to this world? ;)
Обсуждают сегодня