I'm trying to decide how to set up my functions in the prototype for my main library.
Should I use:
Library.prototype.funcA = function () {.....};
Library.prototype.fucnB = function () {.....};
etc..
or
Library.prototype = {
funcA: function () {.....},
funcB: function () {.....},
etc..
};
So basically the first choice adds all my functions to the prototype. The second option replaces the prototype with an object containing all my functions. Does it matter?
I would go with the first option.
You don't want to completely replace the prototype, as you never know what has been added from another project.
If it's something completely self-contained that only you are working on, the second is an ok option. But it is still not a good habit to get into so you don't inadvertently blow away some functionality something else is counting on.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With