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"}
];
asked Nov 10, 2016 at 22:03
Honzík Azjol Havelka
3252 silver badges14 bronze badges
1 Answer 1
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)
answered Nov 10, 2016 at 22:05
Nenad Vracar
122k16 gold badges160 silver badges184 bronze badges
Sign up to request clarification or add additional context in comments.
Comments
Explore related questions
See similar questions with these tags.
lang-js