Skip to content

Instantly share code, notes, and snippets.

@fearphage
Created January 7, 2015 21:51
Show Gist options
  • Select an option

  • Save fearphage/eb439159c7adfc327acd to your computer and use it in GitHub Desktop.

Select an option

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