10 biggest JS pitfalls
axel at rauschma.de
Mon Dec 31 01:17:28 PST 2012
>> I’d be interested in other examples of implicit conversions stumping people.
> What stumped who, when? Any bugs/github issues/blog posts to cite?
No, I think I agree with your assessment that implicit conversion to boolean (the most prevalent implicit conversion) is manageable, possibly even desirable.
I was interested in citations regarding non-bolean implicit conversions. So far, my impression has been that other implicit conversions either worked as people expected (+) or were never triggered (-).
>>> You mean free variables being static errors? That is not a done deal yet.
>> No, I meant the hole of not having a module system that is part of the language. They don’t plug, they *are* the plug. ;-)
>> Sorry for being ambiguous.
> But what's the pitfall? "Lack of a module system" describes a solution more than a symptom.
“I wouldn’t consider that hole a pitfall.” (first quoted line above)
I consider not having modules built into the language as a missing piece, a hole. Are you disagreeing with that assertion? Or with my way of putting things?
But even if you disagree then ES6 modules still have two advantages (as opposed to, say, adopting AMD as part of ES6):
1. We’ﬂl have a common standard (that probably wouldn’t happen otherwise).
2. Easier to analyse statically: http://calculist.org/blog/2012/06/29/static-module-resolution/
>>> Missing properties yielding undefined still burns many JS programmers. Not an implicit conversion, so worth a separate item.
>> In chains? obj.prop1.prop2?
> No, that throws promptly with near-enough blame!
> The problem is the dual of object detection as a useful pattern. When you expect var foo = obj.foo to get an extant property's value, and let foo flow off into complex control flows before being dereferenced, then you have the "come-from" problem.
Right. Automatically creating properties (typos...) and the “assignment vs. definition” issue are relevant here, too.
Dr. Axel Rauschmayer
axel at rauschma.de
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the es-discuss