How to get the first key (not value) of immutable.js map?
basically myMap.first()
will return the value, but I am interested in the key...
I can do a forEach and store first, but must be a better way!
didn't see it in the docs, prob missing it... :/
tx
Sean
Do this -
var firstKey = map.keySeq().first();
Explanation - Get me a lazy sequence of keys of this map, then resolve the first key. Alternatively you can use keys()
method which returns plain old ES6 iterator. It will be less performant though.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With