Chapter 5. The Good Parts
JavaScript is a tricky beast, and knowing the parts that you should avoid is just as important as knowing about the parts you should use. As Sun Tzu says, âknow your enemy,â and thatâs exactly what weâre going to do in the chapter, exploring the dark side of JavaScript and revealing some of the lurking monsters ready to pounce on the unsuspecting developer.
As I mentioned in the Preface, CoffeeScriptâs awesomeness lies not only in its syntax, but in its ability to fix some of JavaScriptâs warts. However, the language is not a silver bullet to all of JavaScriptâs bugbears, and there are still some issues you need to be aware of.
The Unfixed parts
While CoffeeScript goes some length to solving some of JavaScriptâs
design flaws, it can only go so far. As I mentioned previously,
CoffeeScript is strictly limited to static analysis by design, and doesnât
do any runtime checking for performance reasons. CoffeeScript uses a
straight source-to-source compiler, the idea being that every CoffeeScript statement results in an
equivalent JavaScript statement. CoffeeScript doesnât provide an
abstraction over any of JavaScriptâs keywords, such as typeof
, and as such, some design flaws in
JavaScriptâs design also apply to CoffeeScript.
Weâre going to first talk about some issues that CoffeeScript canât fix, and then touch on a few JavaScript design flaws that CoffeeScript does fix.
Using eval
While CoffeeScript removes some of JavaScriptâs foibles, ...
Get The Little Book on CoffeeScript now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.