This question — how to make using an arguments hash for some or all of your arguments fun — has been bugging me for a while. So I just started a tiny new library called argment: <https://github.com/Sidnicious/argment.js>.
Check it out! For the moment, it’s nine lines and does only the simplest case, but heck, I like it. Start with an ordinary function (which never has to deal with the options hash)… function foo(a, b, c){ console.log(a, b, c); } …and argment it: foo = argment(foo, ['a', 'b', 'c']); foo({ a: 'one', c: 'three' }); Useful? What should I add? On Jun 16, 2011, at 6:09 PM, Matthew Bramer 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