Skip to content

Instantly share code, notes, and snippets.

Created Aug 9, 2012
What would you like to do?
A proper clone
// example:
function clone(o) {
return Object.create(
function getOwnPropertyDescriptors(o) {
return Object.keys(o).reduce(getPropertyDescriptor.bind(o), {})
function getPropertyDescriptor(acc, key) {
acc[key] = Object.getOwnPropertyDescriptor(this, key)
return acc

This comment has been minimized.

Copy link

@domenic domenic commented Aug 9, 2012

Nice trick passing a "third argument" to getPropertyDescriptor.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment