Skip to content

Instantly share code, notes, and snippets.

@Odepax
Created September 21, 2019 10:35
Show Gist options
  • Save Odepax/2ff90e065305e5f53219831e6efef542 to your computer and use it in GitHub Desktop.
Save Odepax/2ff90e065305e5f53219831e6efef542 to your computer and use it in GitHub Desktop.
Javascript Object.apply
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