Sorry, but while the big majority of these functions are pretty useless (you might find them in lodash or even in the language itself), the implementations show a big misunderstanding of how JavaScript works.
You can do pretty much anything with Array functions like map, reduce, filter, slice and concat. They are helpful because they do not mutate the original array, but produce a new one.
And finally, it is really not necessary to pollute your code with such ugly names, even if PHP provides them. Next readers won't necessary know a lot about PHP.
This, and you can even use the ...spread operator instead of concat, to create a new array from an existing one.
The above functions are translated a bit too literally from PHP, or perhaps the intention was to make them work for ES5 / lower?
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Sorry, but while the big majority of these functions are pretty useless (you might find them in lodash or even in the language itself), the implementations show a big misunderstanding of how JavaScript works.
You can do pretty much anything with Array functions like
map
,reduce
,filter
,slice
andconcat
. They are helpful because they do not mutate the original array, but produce a new one.And finally, it is really not necessary to pollute your code with such ugly names, even if PHP provides them. Next readers won't necessary know a lot about PHP.
This, and you can even use the ...spread operator instead of concat, to create a new array from an existing one.
The above functions are translated a bit too literally from PHP, or perhaps the intention was to make them work for ES5 / lower?