1

How to collect array of objects in javascript, example i have this array in this case :

var abc = [{"name": "udin", "checked": true}, {"name": "kabayan": "checked": true}, {"name": "hebring"}];

how to get result like this :

abc = [{"name": "udin", "checked": true}, {"name": "kabayan": "checked": true}];

i'm just want to showing only element with "checked" == true

2

1 Answer 1

7

Use js native array filter function like bellow

abc = abc.filter(function(obj){
    return obj.checked;
});
console.log(abc);

It will give you expected output.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.