Skip to content

Instantly share code, notes, and snippets.

@carbide-public
Created January 26, 2021 02:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save carbide-public/dc7f448535d1367a779829050cf99f97 to your computer and use it in GitHub Desktop.
Save carbide-public/dc7f448535d1367a779829050cf99f97 to your computer and use it in GitHub Desktop.
untitled
class MyClass {
a = 1;
b = 2;
constructor(overwrite){
Object.assign(this, overwrite);
console.log(this)
}
}
const test1 = new MyClass() ///a = 1; b = 2
const test2 = new MyClass({a: 2, b : 5}) ///a = 2; b =5;
const test3 = new MyClass({a: 900, b: 1000}); ///a = 900; b = 1000;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment