From the Ember.js documentation:
Person = Ember.Object.extend({
// [..]
});
It’s the first definition of Person, so why is the var statement omitted?
var is also missing in some other places, e.g. Ember.Application.Create or Ember.StateManager.Create.
Guys, I know what happens when var is omitted. But there doesn’t seem to be a good reason to do it, like this it’s just confusing people.
It’s declared globally so Ember and Handlebars can resolve bindings.
In case of a view for example it’s necessary so it can be instantiated in a Handlebars template via the
viewhelper:Handlebars:
JavaScript:
The following example doesn’t work when the controller is declared with a
varstatement, see http://jsfiddle.net/pangratz666/uzsd6/:Handlebars:
JavaScript:
If the controllers are declared on a global available object, the
Appnamespace in this case, the the bindings can be resolved, see http://jsfiddle.net/pangratz666/kUmje/:Handlebars:
JavaScript:
You should take a look at the Emberist ‘s blog about Naming Conventions in
Ember.js.