Created
August 26, 2016 20:08
-
-
Save charmander/94c4f5f9ea9d1578caea99c2438b868f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'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