Disregarding the original question of memory considerations (because it's
obviously where this conversation is going to go)...

Rebecca Murphy did a nice round up of parameter vs option object options.

http://blog.rebeccamurphey.com/objects-as-arguments-in-javascript-where-do-y

The general consensus... Parameters for up to 3 or 4 required params,
otherwise options object.

_jason

On Jun 16, 2011, at 3:29 PM, Amit Kumar <the...@gmail.com> wrote:

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 <remym...@gmail.com> 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/jsmentors@jsmentors.com/
>
> To search via a non-Google archive, visit here:
> http://www.mail-archive.com/jsmentors@googlegroups.com/
>
> To unsubscribe from this group, send email to
> jsmentors+unsubscr...@googlegroups.com
>

 --
To view archived discussions from the original JSMentors Mailman list:
http://www.mail-archive.com/jsmentors@jsmentors.com/

To search via a non-Google archive, visit here:
http://www.mail-archive.com/jsmentors@googlegroups.com/

To unsubscribe from this group, send email to
jsmentors+unsubscr...@googlegroups.com

-- 
To view archived discussions from the original JSMentors Mailman list: 
http://www.mail-archive.com/jsmentors@jsmentors.com/

To search via a non-Google archive, visit here: 
http://www.mail-archive.com/jsmentors@googlegroups.com/

To unsubscribe from this group, send email to
jsmentors+unsubscr...@googlegroups.com

Reply via email to