Getting rid of CoffeeScript’s closure wrapper

Quick and dirty solution: Use the console flag -b (bare). Warning: Kittens will die if you do that! Clean solution: Don’t do that. Usage: coffee [options] path/to/script.coffee -c, –compile compile to JavaScript and save as .js files -i, –interactive run an interactive CoffeeScript REPL -o, –output set the directory for compiled JavaScript -j, –join concatenate … Read more

When does the “fat arrow” (=>) bind to “this” instance

The fat arrow binds at 3 occasions when declaring a method when declaring a function within a method when declaring a function in global context 1. When declaring a method When the Coffeescript compiler encouters the following syntactical pattern within a class declaration class A somemethod: (paramlist) => This will yield the following code within … Read more

How does CoffeeScript’s existential operator work?

The documentation says this about ?: CoffeeScript’s existential operator ? returns true unless a variable is null or undefined, which makes it analogous to Ruby’s nil? so of course this will say “No taco!”: taco = undefined if taco? console.log “fiesta!” else console.log “No taco!” Your taco is explicitly undefined so taco? is false. CoffeeScript … Read more