Home » JavaScript » Prototype

Prototype

Javascript Prototype methods vs Object methods

In JavaScript, when you define an object, you can attach it’s functions in two different ways. Inside object’s constructor function, using this.func = function(){...} Using prototype. i.e. Obj.prototype.func = function() {...}. In both approaches, the function func() will be accessible to all the instances of your object. But which one is the best way to use? In short: Use prototype ...

Read More »