Reputation:
I noticed that in the app.js
file produced by Ember CLI (v0.1.12), they're using:
var App = Ember.Application.extend({...})
but in the introduction guide, they're using:
window.App = Ember.Application.create({...});
Is there any difference in outcome between these two (create vs. extend) ways of creating an Ember application?
Upvotes: 5
Views: 958
Reputation: 4434
As documented in the Ember documentation extend
Creates a new subclass, while
create
Creates an instance of a class.
The main difference is that by using extend
you can override methods but still access the implementation of your parent class by calling the special _super() method
but create
does not afford that ability.
The linked docs have good code examples specifically with regards to your question.
See
The create() on line #17 creates an instance of the App.Soldier class. The extend() on line #8 creates a subclass of App.Person. Any instance of the App.Person class will not have the march() method.
and the code proceding that quote.
Upvotes: 1