Craig Maloney

[Blog] JavaScript for the Frustrated Programmer

Craig Maloney at

(http://feedproxy.google.com/~r/CraigMaloney/~3/t7SttJVP0kE/)

Once again I find myself confronted with the peculiarities of JavaScript's type coercion (as explained in the first chapter of Eloquent JavaScript). I ran into these before and it frustrated me how JavaScript would do conversions that were heavily weighted towards strings:

"5" + 1  // Returns '51' because of string concatenation.
"5" - 1  // Returns 4 because strings cannot be subtracted.

5 + '1'  // Returns '51'
5 - '1'  // Returns 4

I recall this bothering me pretty hard when I tried the learning challenge last time, but I'm older and wiser now (and unemployed). Plenty of people have been able to hold their noses for long enough to be productive with JavaScript. If I'm going to get anywhere with this language I need to learn this skill too.

Douglas Perkins likes this.

You know, I think learning to hold our noses is a very valuable, general skill to have as a developer. It seems all the tools I have to use are full of annoying warts and pitfalls. *sigh*

Charles Stanhope at 2016-10-14T17:52:30Z

Craig Maloney likes this.

And of course all the tools I create as a developer are also full of their own annoying warts and pitfalls. *sigh*

Charles Stanhope at 2016-10-14T17:58:49Z

Craig Maloney likes this.