Access model data as an array

Is there any way of access the data from a model (like name, surname, etc.) in a array way instead of specifying the name of its attributes?

I mean, something like this:


instead of

Any model in Ember is an object. How do you imagine accessing an object property by its “number”? There’s no such thing as the “first” or any other key in the object. They are unordered by deign and all that properties may be sorted by browser.

I guess my best tip here is to use an array of object keys. Something like this:

var keys = Object.keys(model);
var key = keys[0];
var prop = model[key];

But I’d rather obtain a property by its name, it’s the only right answer here.

Make a mistake - fix a mistake.

Look what I’ve found in API: Model - 4.6 - Ember API Documentation

Thus you actually can do that like this

var key = model.fields[0];
var prop = model[key];

Sorry for messing up.

Don’t worry @od1n, I’m learning so any help, even if it’s a correction to my understandings is great for me :slight_smile: thank you very much for your help, both approach are very interesting!

The documentation for Ember arrays is here: EmberArray - 4.6 - Ember API Documentation

Sample methods: