I didn’t know this!
“The null value … can only be assigned by your code.”
From Object-Oriented JavaScript by Stoyan Stefanov
I didn’t know this!
“The null value … can only be assigned by your code.”
From Object-Oriented JavaScript by Stoyan Stefanov
This will alert “10″:
var num = num || 10;
alert(num);
But so will this:
num = 0;
var num = num || 10;
alert(num);
Watch out for the cases where num is “falsey“.
The following convert to false when applied to a double negation in JavaScript:
""
null
undefined
0
NaN
“… if you try to return anything [from a constructor] that is not an object [emphasis mine], the constructor will proceed with its usual behavior and return this.”
From Object-Oriented JavaScript by Stoyan Stefanov