Reputation: 325
can someone tell me please how to get index of an associative array??
for example index of key:".launchPad-plankovy"??
var droppableClasses = [
{key:".stackDrop-plankovy", value:".card-plankovy"},
{key:".launchPad-plankovy", value:".card-plankovy"}
];
Upvotes: 0
Views: 2006
Reputation: 122047
With ES6 you can use findIndex()
like this.
var droppableClasses = [{
key: ".stackDrop-plankovy",
value: ".card-plankovy"
}, {
key: ".launchPad-plankovy",
value: ".card-plankovy"
}];
var index = droppableClasses.findIndex(function(e) {
return e.key == '.launchPad-plankovy';
})
console.log(index)
Upvotes: 3