Skip to content

Instantly share code, notes, and snippets.

@servatj
Created October 29, 2019 11:17
Show Gist options
  • Save servatj/2b8c11702882bf8397357bc7dc970186 to your computer and use it in GitHub Desktop.
Save servatj/2b8c11702882bf8397357bc7dc970186 to your computer and use it in GitHub Desktop.
Convert instance class to plain object.
const classToObject = theClass => {
const originalClass = theClass || {}
const keys = Object.getOwnPropertyNames(Object.getPrototypeOf(originalClass))
return keys.reduce((classAsObj, key) => {
classAsObj[key] = originalClass[key]
return classAsObj
}, {})
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment