I see this isn't possible (in JavaScript), would this be due to serialization for persistance?
ActionScript3 does allow object instances as keys flash.utils.Dictionary
Then again, string Id's would serve the same uniqueness purpose of the instance, right?
This is what ES6 Map
is for, it allows to use an object as key:
var map = new Map();
var obj1 = {};
var obj2 = {}; // identical, but not the same
map.set(obj1, 'value');
map.get(obj1); // 'value'
map.get(obj2); // undefined
Demo (Firefox and IE 11): http://jsbin.com/ehIgEha/1/edit?js,console, browser support: http://kangax.github.io/compat-table/es6/#Map
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