简体   繁体   English

JavaScript中的关联数组的IndexOf

[英]IndexOf an associative array in javascript

can someone tell me please how to get index of an associative array?? 有人可以告诉我如何获取关联数组的索引吗?

for example index of key:".launchPad-plankovy"?? 例如键的索引:“。launchPad-plankovy”?

        var droppableClasses = [
           {key:".stackDrop-plankovy", value:".card-plankovy"}, 
           {key:".launchPad-plankovy", value:".card-plankovy"}
        ];

With ES6 you can use findIndex() like this. 使用ES6,您可以像这样使用findIndex()

 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) 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM