10 biggest JS pitfalls
andrea.giammarchi at gmail.com
Sun Jan 6 01:37:50 PST 2013
Axel, it wasn't referred to you explicitly, rather to all those developers
still wining about this == null problem which has never been in my daily,
real work, code.
value === undefined || value === null
in a language where undefined and null are different and for a good reason
(not defined is different from defined as null)
that one, against
value == null
who wins ... and why, if specs say latter one is equivalent? because!
Same is for falsy, I don't even want to start talking about it ... you
learn how take advantage and avoid mistaken them when needed.
Do not think what you learned at University about Java is the way every
programming language should be .... do not think other
programming/scripting languages are inferior because of your
inflexible, indoctrinated knowledge about programming, just learn something
more, read specs, those are small for what the language offer in JS case,
and stop moaning about null and undefined, falsy, and all those script
thing stat made scripting historically easier and often more productive
than strict programming languages.
The "you" I have used here is not about you .. you know these things, so
why even bothering calling them pitfalls ... pitfalls are those nobody can
understand, your 10 points are my breakfast, if you don't mind passing the
As summary, in my opinion, there's no need to write top 10 here: these are
pointless, completely subjective, and **always** available, no matter which
one is the topic.
These, are not what we need ... Object.observe idea/mechanism/possibility
is, the fat null is == undefined is not stopping anyone, and never did,
from creating amazing stuff with the Web or, lately, the server.
Just my 2 cents, don't take it personal, please!
On Sun, Jan 6, 2013 at 12:14 AM, Axel Rauschmayer <axel at rauschma.de> wrote:
> > Exactly Brendan, I could not agree more and this is my No. 1 pitfall
> about JS: developers often not doing real work complaining about stuff that
> developers doing real work don't even care about or never ever had to worry
> I don’t follow. Who are these people not doing “real work”? And I don’t
> think discussing the language qualifies as complaining.
> > In any case they can learn and understand the feature/problem using the
> feature when needed, avoiding its weakness when necessary.
> > About falsy and truthy, null and undefined, who cares ... seriously, and
> to be honest, that's not a pitfall, is rather a feature when needed as it
> is for all other scripting languages as long as you know what you are doing
> ... and no programming language will save you if you don't know what you
> are doing and it's your duty, as developer, to understand the language you
> are using if that's your job.
> “Warts” is probably a better term than “pitfalls”.
> > Again, about falsy ... if I see a glass empty, it does not mean I used a
> microscope to understand no water is left in the whole glass surface ... I
> just consider that empty and I add water on top.
> > Engineers have the tendency to over complicate even simple tasks as the
> one I've just described ... what is the benefit? What is the result? That
> the day falsy values in JS will disappear libraries authors will implement
> an isFalsy(value) function/method and use it 90% of the time regretting the
> trick with == disappeared ... isn't it ;-)
> What is the trick with ==? Note that == does not respect truthiness or
> > 2 == true
> > 2 == false
> > '2' == true
> > '2' == false
> Dr. Axel Rauschmayer
> axel at rauschma.de
> home: rauschma.de
> twitter: twitter.com/rauschma
> blog: 2ality.com
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the es-discuss