Created
October 23, 2019 12:41
-
-
Save Himenon/3e210640d96557cd13cdb10b49ece2fe to your computer and use it in GitHub Desktop.
すでに生成されたインスタンスから、新しいインスタンスを生成するFunction
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
/** | |
* すでに生成されたインスタンスから、新しいインスタンスを生成する | |
* https://stackoverflow.com/questions/41474986/how-to-clone-a-javascript-es6-class-instance | |
* @param instance | |
*/ | |
const cloneInstance = <T>(instance: T): T => Object.assign(Object.create(Object.getPrototypeOf(instance)), instance); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment