If you've created 100,000 circles, it turns out that for each of the object/circle, a unique updateSize function lives inside each of the 100,000 objects! Notice how much memory this would consume!
Therefore, for ES5, when instance methods are created, you could use the following convention instead.
Prototypes
Note that in ES5, we could create instance methods by using this.{{name of the function}}. For example, for a class Circle, you may do:
function Circle(size){ this.size = size; this.updateSize = function(new_size){ this.size = new_size; } } var circle1 = new Circle(5);
If you've created 100,000 circles, it turns out that for each of the object/circle, a unique updateSize function lives inside each of the 100,000 objects! Notice how much memory this would consume!
Therefore, for ES5, when instance methods are created, you could use the following convention instead.
...