Would you like to clone this notebook?

When you clone a notebook you are able to make changes without affecting the original notebook.

Cancel

Making something serializable

node v10.24.1
version: 1.0.0
endpointsharetweet
class Person { constructor(firstName, lastName) { this.firstName = firstName; this.lastName = lastName; } } let bart = new Person('Bart', 'Simpson'); bart.valueOf() // this is not what we want because this is a complex instance
class PersonOfValue extends Person { valueOf() { const { firstName, lastName } = this; return { firstName, lastName }; } } let bartOfDistinction = new PersonOfValue('Bart', 'Simpson'); bartOfDistinction.valueOf(); // this is what we want
Loading…

no comments

    sign in to comment