javascript - Which of these prototype declarations is better and why? -
this question has answer here:
i'm trying decide how set functions in prototype main library.
should use:
library.prototype.funca = function () {.....}; library.prototype.fucnb = function () {.....}; etc.. or
library.prototype = { funca: function () {.....}, funcb: function () {.....}, etc.. }; so first choice adds functions prototype. second option replaces prototype object containing functions. matter?
i go first option.
you don't want replace prototype, never know has been added project.
if it's self-contained working on, second ok option. still not habit don't inadvertently blow away functionality else counting on.
Comments
Post a Comment