3 ms·
It the compiled code compatible with the Strict mode in ECMAScript 5? Did the language remove any of the "bad parts"?
by pdelgallego 16y ago
It the compiled code compatible with the Strict mode in ECMAScript 5?
Did the language remove any of the "bad parts"?
- jashkenas 16y agoIn general, the compiled code should pass JavaScript lint without errors, and can be compatible with ECMA5 strict mode, but does not enforce it (because strict mode has a lot to do with runtime implementation, which we can't do anything about). Looking at page 233 of the spec: http://www.ecma-international.org/publications/files/ECMA-ST/ECMA-262.pdf http://www.ecma-international.org/publications/files/ECMA-ST... Most of the strict mode restrictions have to do with "arguments" and "eval", which CoffeeScript doesn't affect. The two bits that we do enforce are: "Assignment to an undeclared identifier or otherwise unresolvable reference does not create a property in the global object," and "Strict mode code may not include a WithStatement" -- the former because variable scoping is automatic, and the latter because there is no "with" statement in CoffeeScript. But there are a number of other, more important bad parts that are omitted, beyond strict mode: JavaScript's string-based switch statement, coercive equality checks, named function statements, trailing commas, and so on...