I love that CoffeeScript compiles == into the JavaScript === operator. But what if you want the original JS == semantics? Are they available? I’ve pored over the documentation and can’t find anything enabling this.
More generally, is there a way to inline plain JS into my CoffeeScript code so that the compiler doesn’t touch it?
I’d prefer to avoid editing the compiled JavaScript output, since I’m using Chirpy to auto-generate it in Visual Studio.
Yes, here’s the documentation. You need to wrap the JavaScript code in backticks (
`). This is the only way for you to directly use JavaScript’s==in CoffeeScript. For example:CoffeeScript Source [try it]
Compiled JavaScript
The specific case of
== null/undefined/void 0is served by the postfix existential operator?:CoffeeScript Source [try it]
Compiled JavaScript
CoffeeScript Source [try it]
Compiled JavaScript