You can get the key sequence from the map:
let index = map.keySeq().findIndex(k => k === key);
See the docs for more details .
In addition, you can explicitly iterate over the keys and compare them:
function findIndexOfKey(map, key) {
let index = -1;
for (let k of map.keys()) {
index += 1;
if (k === key) {
break
}
}
return index;
}
source
share