0

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"}
        ];

1 Answer 1

3

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)

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.