The new optional parameter for ES6 only cares about undefined.
undefined
function myFunc(a, b = 0) { console.log(a,b); } myFunc(1); // 1 0 myFunc(1,null); // 1 null myFunc(1,undefined); // 1 0 myFunc(1,getSomeNonExistingValue()); // 1 (null or 0)
Wouldn't it be simpler to use undefined instead of null everywhere? Just stop using null?
null
Yeah, this has tripped me a couple of times...
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
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.
The new optional parameter for ES6 only cares about
undefined
.Wouldn't it be simpler to use
undefined
instead ofnull
everywhere? Just stop usingnull
?Yeah, this has tripped me a couple of times...