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"}
 ];
asked Nov 10, 2016 at 22:03

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)

answered Nov 10, 2016 at 22:05
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

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.