Quantcast
Viewing all articles
Browse latest Browse all 4827

Initializing arrays in Ember

@jfschaff wrote:

I just had a hard time finding how to define an array with Ember’s new ES6 module imports. So here it is for others who might have the same question:

import { A } from '@ember/array';
...
this.set('someVar', A());             // empty Emberish array
this.set('someOtherVar', A([1,2,3]));

As explained in the doc here

A() is not needed if EmberENV.EXTEND_PROTOTYPES is true (the default value). However, it is recommended that you use A() when creating addons for ember or when you can not guarantee that EmberENV.EXTEND_PROTOTYPES will be true.

Posts: 1

Participants: 1

Read full topic


Viewing all articles
Browse latest Browse all 4827

Trending Articles