I'd like to use functions as keys in a javascript object. The following works, at least in Chrome:
var registry = {};
function Foo(){ };
function Bar(){ };
registry[Foo] = 42;
registry[Bar] = 43;
alert(registry[Foo] + " < " + registry[Bar]);
Is this covered by the standard? By which browsers is it supported?
addEventListenerandremoveEventListenerwork?addEventListenerwill not add same callback twice for same event. And obviouslyremoveEventListenerneeds to recognise the callback being removed. I did not understand the Rice's theorem, but in my mind a function can be represented as a pointer. Why isn't this used? Update: keys of type object do not work either.