K
K
Kusmich2015-10-28 23:24:34
JavaScript
Kusmich, 2015-10-28 23:24:34

How to get all the same properties from an associative array?

There is an associative array from which you need to take all the name properties and push it into another array. But even it is not possible to do this, it turns out to take the last current. What is the best way to do this?

Here is the array itself:

var json_date = [{
    "dills": {
        "1": {
            "name": "soker",
            "time": "13:00",
            
        },
        "2": {
            "name": "footbol",
            "time": "15:00",
           
        },
        "3": {
            "name": "bysbol",
            "time": "11:00",
            
        }
    }
}]

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey Voronkov, 2015-10-29
@Kusmich

If you are using jquery then you can

var names = $.map(json_date[0]["dills"], function(item){return item.name});

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question