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()
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
The two are intended to be equivalent. To quote the Backbone.js changelog:
Both CoffeeScript’s
Child extends Parentand Backbone’sChild = Parent.extend()do three important things:Child.prototypetonew ctor, wherectoris a function whose prototype isParent.prototype. That establishes prototypal inheritance.Parent‘s static properties ontoChild.Child.__super__ = Parent. This is mainly to support CoffeeScript’s Ruby-likesuperkeyword inChild‘s methods.