Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

In Ember.js, what is the difference between [] and Ember.A([])?

Tags:

ember.js

While looking through apps written with Ember.js, I noticed that sometimes arrays are defined with a call to Ember.A() and sometimes array literals are used. When I ran Ember.A([1]) in the browser console, the return value looks just like an array and arrays created using array literals had the Ember.js methods pushObject and friends. Is the call to Ember.A() just a way to define an Ember.Array when you don't use prototype extensions? Otherwise are arrays all created equal?

like image 806
hekevintran Avatar asked Apr 27 '12 05:04

hekevintran


People also ask

What is Ember array?

Class EmberArrayThis mixin implements Observer-friendly Array-like behavior. It is not a concrete implementation, but it can be used up by other classes that want to appear like arrays. For example, ArrayProxy is a concrete class that can be instantiated to implement array-like behavior.

How does Ember js work?

Ember. js uses Handlebars, a lightweight templating engine also maintained by the Ember team. It has the usual templating logic, like if and else , loops and formatting helpers , that kind of stuff. Templates may be precompiled (if you want to cleanly organize them as separate .

What is a model in Ember?

In Ember Data, models are objects that represent the underlying data that your application presents to the user. Note that Ember Data models are a different concept than the model method on Routes, although they share the same name.

Is Ember js a library or a framework?

Ember. js is a JavaScript framework for creating ambitious web applications.


1 Answers

Your question contains the correct answer: Ember.A() just a way to define an Ember.Array when you have turned off the prototype extensions. You'll notice that Ember's internal code always uses Ember.A().

like image 136
Luke Melia Avatar answered Oct 06 '22 00:10

Luke Melia