Niko Köbler

Software-Architect, Developer & Trainer

Having fun with JavaScript

June 11, 2014

You all know this WAT movie from Gary Bernhardt... Summarized it is this:

Strange behaviour in JavaScript, especially the "{}+[]" and "[]+{}" results. As these are sums, the order of the summands should be no matter, but it is. Weird.

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!

What is it then? ;-)

Tags: #javascript    #fun    #codinghorror   

« Review of JAX 2014 Project Avatar at JavaOne 2014 »

AWS certified

Serverless Computing

My book on Serverless Computing (german language only) is available!

Order now!