how well do you know your “null”s and “undefined”s?
write down what you expect the result of each operation to be. run them in a javascript console (Chrome, Firefox/Firebug, Safari). compare, verify, contrast, and, for fun, give yourself a score out of “3/4 donut”.
// Equality null == undefined null === undefined !null == !undefined !null === !undefined // addition and concatenation null + '' undefined + '' null + 1 undefined + 1 // fun with enumerations test = []; test.push(null); console.log(test) test = []; test.push(undefined); console.log(test) {null:2} {undefined:2} {a:null} {a:undefined}
[More programming riddles]