Created
September 21, 2019 10:35
-
-
Save Odepax/2ff90e065305e5f53219831e6efef542 to your computer and use it in GitHub Desktop.
Javascript Object.apply
This file contains hidden or 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
Object.prototype.apply = function apply(/** @type {{ [prop: string]: any }|((it: any) => void)} */ init) { | |
if (typeof init == "function") { | |
init(this) | |
} else { | |
Object.assign(this, init) | |
} | |
return this | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment