Skip to content

Instantly share code, notes, and snippets.

@fearphage
Created January 7, 2015 21:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fearphage/eb439159c7adfc327acd to your computer and use it in GitHub Desktop.
Save fearphage/eb439159c7adfc327acd to your computer and use it in GitHub Desktop.
Python's defaultdict
function defaultDict(constructor) {
return new Proxy({}, {
get: function(object, property) {
return property in object
? object[property]
: object[property] = constructor()
;
}
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment