Created
October 29, 2019 11:17
-
-
Save servatj/2b8c11702882bf8397357bc7dc970186 to your computer and use it in GitHub Desktop.
Convert instance class to plain object.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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