Define constructor prototype with object literal
问题 Which method below is best to define a constructor prototype and why? Method 1: MyConstructor.prototype.myFunction1 = function(){}; MyConstructor.prototype.myFunction2 = function(){}; Method 2: MyConstructor.prototype = { myFunction1: function(){}, myFunction2: function(){} }; I'm mostly concerned about speed. Thanks! 回答1: I would say there wouldn't be much of a difference. Using an object literal to assign to the Object.prototype is something you can't do if you're assigning the prototype