Skip to content

Instantly share code, notes, and snippets.

Avatar

Shuping LIU liushuping

View GitHub Profile
@liushuping
liushuping / gist:80ed29243e3c2f815ed6
Last active Aug 29, 2015
A map implementation in JavaScript
View gist:80ed29243e3c2f815ed6
/*
A JavaScript object notition is by nature a map, however there are limitations of it: the map is not empty,
the Object prototype properties are mapped keys which are unexpected. For below example, the "toString" is by
default a key in the map.
var x = {};
x["toString"]; // function toString()
But with the Object.create method, we can create a real empty map object. What needed is just to pass null to
the method.