Instances are like Plain Old JavaScript Objects (POJOs) in many ways. You can assign values to them however you like, and generally treat them the same: lettom=newPerson();letyehuda={};tom.name='Tom Dale';yehuda.name='Yehuda Katz';console.log(tom);// Person {name: "Tom Dale"}consol...
A WeakMap can be used to improve the performance of the above approach, in exchange for even more clutter. WeakMaps associate data with Objects (here, class instances) in such a way that it can only be accessed using that WeakMap. So, we use the scoped variables method to create a pr...