Created
June 1, 2015 20:43
-
-
Save pseudosavant/3ecddab62555c81c46a0 to your computer and use it in GitHub Desktop.
True hash maps / bare objects
This file contains hidden or 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
// See: http://ryanmorr.com/true-hash-maps-in-javascript/ | |
// This creates a 'bare object' that can be used as a true hash map. | |
// Safe to use `for...in` because it doesn't inherit `Object.prototype` | |
var map = Object.create(null); | |
map instanceof Object; // false | |
Object.prototype.isPrototypeOf(map); // false | |
Object.getPrototypeOf(map); // null |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment