Back to questions
JuniorTheoryCommon
What does the program print?
console.log(0 == "", null == undefined, null === undefined);true true false
- Expecting
0 == ""to befalse:==converts both sides to one type first, and the empty string becomes the number0, so the two sides are equal. - Expecting
null === undefinedto betrue:===never converts types, andnullandundefinedare different types, so it givesfalse.
- What does
0 === ""print, and why does it differ from0 == ""? - What does
null == 0print, given thatnull == undefinedistrue?