2

When protyping functions (in most code I've seen) they are generally written like so:

function MyFunc() { }
MyFunc.prototype.render1 = function() { };
MyFunc.prototype.render2 = function() { };
MyFunc.prototype.render3 = function() { };

However this can be shortened like so:

function MyFunc() { }
MyFunc.prototype = {
    render1: function() { },
    render2: function() { },
    render3: function() { }
};

From my understanding the shortended way will completely override the functions prototyped properties, as opose to adding one. Is there any other downsides to writing the protoyped functions in this manner?

Gary Green
  • 22,045
  • 6
  • 49
  • 75

1 Answers1

1

I don't know any issues writing the second way - which I use also - because root prototype is Object, and you are passing an object so...

dmidz
  • 896
  • 7
  • 20