Skip to content

Instantly share code, notes, and snippets.

@pseudosavant
Created June 1, 2015 20:43
Show Gist options
  • Save pseudosavant/3ecddab62555c81c46a0 to your computer and use it in GitHub Desktop.
Save pseudosavant/3ecddab62555c81c46a0 to your computer and use it in GitHub Desktop.
True hash maps / bare objects
// 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