DEV Community

Discussion on: 10 Practical JavaScript Tricks

Collapse
 
oli8 profile image
Olivier

Nothing wrong with the reduce here.

Collapse
 
clydegrey profile image
Clyde

You can skip the initial value in your reduce, but now you have to check that the array length is greater than zero.

So you've introduced a serious bug in your application to save typing two characters.

Also as others have pointed out use of var is discouraged, use of arguments keyword is discouraged and a few other bad practices.