What are the fundamental differences between utilizing CoffeeScript extends vs. Backbone.js extend?
For example, how is
class User extends Backbone.Model
different from
User = Backbone.Model.extend()
The two are intended to be equivalent. To quote the Backbone.js changelog:
0.3.0: Backbone classes may now be seamlessly inherited by CoffeeScript classes.
Both CoffeeScript's Child extends Parent and Backbone's Child = Parent.extend() do three important things:
Child.prototype to new ctor, where ctor is a function whose prototype is Parent.prototype. That establishes prototypal inheritance.Parent's static properties onto Child.Child.__super__ = Parent. This is mainly to support CoffeeScript's Ruby-like super keyword in Child's methods.If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With