Personally, I prefer the single object parameter approach. Like you say, it's much more maintainable; if you ever add or remove parameters, none of your client code needs to be changed. You also avoid having to remember parameter order when calling a method.
-Amit On Thu, Jun 16, 2011 at 6:09 PM, Matthew Bramer <[email protected]> wrote: > Please excuse my lack of correct terminology (feel free to correct it!), > but I have an ongoing debate where I work about this. I see some people > build up their functions like this: > > function ManyParams(param1, param2, param3, param4, param5, param6) { > //stuff > } > > I say *not* to do that and just have one object as your parameter: > > function OneParam(options) { > //stuff > } > > My question to you guys is, which approach uses memory the most efficient? > I've been told that using an object would lengthen the script and will add > weight to it. (I don't really agree here) > I see a lot of libraries using the approach that I describe, using an > object as a parameter. It seems that it's the easiest to maintain as well. > > > I'd love to know if there is a fiddle out there that could prove the > pros/cons of both. On that note, how could I measure the difference in > memory usage? > > Thanks for your time, > Matt > > -- > To view archived discussions from the original JSMentors Mailman list: > http://www.mail-archive.com/[email protected]/ > > To search via a non-Google archive, visit here: > http://www.mail-archive.com/[email protected]/ > > To unsubscribe from this group, send email to > [email protected] > -- To view archived discussions from the original JSMentors Mailman list: http://www.mail-archive.com/[email protected]/ To search via a non-Google archive, visit here: http://www.mail-archive.com/[email protected]/ To unsubscribe from this group, send email to [email protected]
