Hacker News
new
|
past
|
comments
|
ask
|
show
|
jobs
|
submit
login
kevincennis
on July 10, 2015
|
parent
|
context
|
favorite
| on:
Don't use || to set default values in JavaScript
In ES5+, the global `undefined` is immutable, so it should be pretty safe unless someone declared a local `undefined` var in an outer scope.
arnehormann
on July 10, 2015
[–]
I use "var undef;" at the top of a function and never set it to a value. Comparison with === is the same as with undefined. And it's nice for minification.
Guidelines
|
FAQ
|
Lists
|
API
|
Security
|
Legal
|
Apply to YC
|
Contact
Search: