Having fun with JavaScript
June 11, 2014
Tags: #javascript #fun #codinghorror
You all know this WAT movie from Gary Bernhardt... Summarized it is this:
Playing around with the relational operator "="... - there are some issues you should consider when programming in JavaScript (nothing new, but always a pleasure):
Although "undefined" and "null" are different... comparators. But what are they? Objects? Primitives? From outer space? null is an object, but undefined is... well, undefined. So they are different. But "==" does not do a comparison on the type, only on the value (implicit type conversion included). The following example also shows this:
So, always have this in mind, when dealing with JavaScript!
And, usage of "===" is most of the times the right choice!
But...
What is it then? ;-)