paul
paul

Reputation: 13471

Iterate over map keys

I´m using kind of an object map on jQuery

  unitPerRestrictions[restriction]= product.quantity.numberOfUnits;

What I would like now is iterate over the keys to extract the values and use the key for other business logic. I cannot find a proper way to do this on jQuery Map and other implementations that I saw did not works

$.map(list, function(obj, index) {
    if(obj.prop2 == "yutu") {
        return index;
    }
})

Upvotes: 0

Views: 105

Answers (1)

Jonathan.Brink
Jonathan.Brink

Reputation: 25383

You can use jQuery's each function.

var targetKey;
$.each(list, function(key, value) {
    if(value === "yutu") {
        targetKey = key;
    }
});

Upvotes: 1

Related Questions