0

Hey im having trouble handling an array. On console i write (ember)

this.get('model');

Which returns

[a, a, a]

Each "a" itself contains of

fname: "fsafasPerson1"
gender: a
id: 1
lname: "fasFirst"

What i would like is to get each "a's" fname for starters.

    fname : "This is the first name"
    fname : " 2nd"
    fname : "third" 

Working example

var fnames = [];
var array = this.get('model')
$.each(array, function(array, obj) {
    fnames.push(obj.fname);
});
console.log(fnames);

Cheers

Kristjan

1 Answer 1

1

Here is what you can do,

var fnames = [];

$.each(obj, function(i, obj) {
    fnames.push(obj.fname);
});
console.log(fnames); // array of fname
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.