How can I get a key in a JavaScript ‘Map’ by its value?

I have a JavaScript 'Map' like this one

let people = new Map();
people.set('1', 'jhon');
people.set('2', 'jasmein');
people.set('3', 'abdo');

I want some method to return a key by its value.

let jhonKey = people.getKey('jhon'); // jhonKey should be '1'


Read more here: https://stackoverflow.com/questions/47135661/how-can-i-get-a-key-in-a-javascript-map-by-its-value

Content Attribution

This content was originally published by Engineer Passion at Recent Questions - Stack Overflow, and is syndicated here via their RSS feed. You can read the original post over there.

%d bloggers like this: