Skip to content

Instantly share code, notes, and snippets.

@luijar
Created September 25, 2015 23:29
Show Gist options
  • Save luijar/e447d7fb78bf5b2600d9 to your computer and use it in GitHub Desktop.
Save luijar/e447d7fb78bf5b2600d9 to your computer and use it in GitHub Desktop.
Copy on change in person class
class Person {
constructor(firstname, lastname) {
this._firstname = firstname;
this._lastname = lastname;
}
// returns a new copy of the object
set firstname(f) {
return new Person(f, this._lastname);
}
//...
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment