Skip to content

Instantly share code, notes, and snippets.

@charmander
Created August 26, 2016 20:08
Show Gist options
  • Save charmander/94c4f5f9ea9d1578caea99c2438b868f to your computer and use it in GitHub Desktop.
Save charmander/94c4f5f9ea9d1578caea99c2438b868f to your computer and use it in GitHub Desktop.
'use strict';
var bracketMapKey = Symbol('bracketMapKey');
Object.prototype[Symbol.toPrimitive] = function () {
return this[bracketMapKey] || (this[bracketMapKey] = Symbol());
};
var map = {};
var key = ['some object'];
map[key] = 5;
console.log(key in map); // true
console.log(['some object'] in map); // false
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment