Two gotchas every CoffeeScript and Backbone.js developer should know

May 21, 2013 seantheprogrammer coffeescript javascript backbone.js Two gotchas every CoffeeScript and Backbone.js developer should know If you’re a Ruby developer working with Rails, at some point you’re going to need to work with JavaScript. While the two languages have many similarities, the fundamental differences in their object models can be quite jarring. CoffeeScript helps to provide a more Ruby-like syntax, but if you’re not careful you can introduce bugs to your code in surprising ways. Let’s look at an example. Let’s say we have an expensive operation, and need to cache the result. In CoffeeScript, we might write the this code as: class GiantRobot smashCache: {} smashInto: (other) => @smashCache[other] ||= @expensiveCalculations(other) However, this code leads to a surprising problem when we start smashing things together. ralph = new GiantRobot() voltron = new G...