I would like to use functions as keys in JavaScript. I know that for js object, functions are converted to "toString" form. That is a problem if two functions have same body.
var a = function() {};
var b = function() {};
var obj={};
obj[a] = 1;
obj[b] = 2;
The value of obj[a] will contain 2.
If I use a Map it seems to be working fine.
var a = function() {};
var b = function() {};
var map = new Map();
map.set(a, 1);
map.set(b, 2);
The value of map.get(a) will return 1 and map.get(b), 2.
Is that a standard behaviour supported by all browsers or is this just a chrome browser implementation of Map collection? Can I relay on this? How functions are hashed in maps?