I’ve been using Javascript lately and it has actually been quite a pleasure to use. I never thought I would say that.
I think my original discomfort with Javascript is a natural one. To me, things were too inconsistent and so I was never confident that what I was writing would translate properly. Java programmers often feel the same way when moving to C/C++.
Ultimately, it comes down to understanding the language’s design goals. Javascript’s goals are a bit strange and at times ugly; however, you don’t mind it once you’ve learned to ignore those bad parts. You learn to have discipline rather than trust Javascript’s forgiving nature (which is often the cause of confusion). The rest is extremely flexible, convenient and powerful.
One bit I find amusing with Javascript is NaN. Arguably, NaN is a bit quirky in most languages, but I never realized how much so until Javascript. (For those of you that don’t know, NaN stands for “not a number”). Consider:
typeof NaN === 'number'; // true
NaN === NaN; // false
NaN !== NaN; // true
On another note, I was thinking on the train ride to work about what the worse possible interview questions would be. For some reason, I can see myself interviewing some poor college kid in the future and being extremely evil, possibly as a joke. I can imagine some triviality like this one making that list. For example, the question would be: Fill in the blank:
___ === ___; // false
___ !== ___; // true
And the hint would be:
typeof ___ === 'number'; // true
Another terrible question was: “Find x strings that match the regular expression y”. I wonder if asking them to build a simple regular expressions matcher is reasonable though.
Leave a comment