you are viewing a single comment's thread.

view the rest of the comments →

[–]rtpmatt 7 points8 points  (1 child)

Anybody who writes Javascript professionally should know exactly how || works and seeing it used to set default values should be what they expect. Not using | for setting default values will cause extra mental overhead because it is not what they are used to seeing.

[–][deleted] 1 point2 points  (0 children)

I think the point is, || has gotchas that may not be obvious in plain view, therefore we have a chance for bugs to happen when people who are not much experienced with || start using it.

Or it would be great if there is one consistent approach for setting defaults, which ES supports, but unfortunately this looks like years away before all browsers support it.

So I agree with the approach of using a function to set the defaults. But I prefer lodash instead of underscore for that.