Skip to content

Instantly share code, notes, and snippets.

View liushuping's full-sized avatar

Shuping LIU liushuping

  • Beijing, China
View GitHub Profile
@liushuping
liushuping / gist:80ed29243e3c2f815ed6
Last active August 29, 2015 14:23
A map implementation in JavaScript
/*
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.