Hi Let's say you go for B), there's a good pattern you can use explained here: http://enterprisejquery.com/2010/08/javascript-parameter-patterns-with-extend-and-beyond/
I personally go for option B) when I cannot remember the order of the arguments or there simply are too many (> 3). Cheers tj On 13.01.2011, at 17:37, Arlo wrote: > I am developing a JS API for my employer and I constantly ask myself > how I should accept params into my methods. So I figured I would ask > the professionals. > > Here is my scenario: > 1.) I know a handful of basic methods that I need to implement right > now. > 2.) I do not know if functionality in these methods will expand in the > future > > Example Method: > A.) function drawPolygon( points, polyOptions ) { ... } > B.) function drawPolygon( options ) { ... } > > I feel that with option B I can expand functionality a lot easier than > with option A. Does anyone have advice or common pitfalls when taking > approach B? I appreciate any input. > > > ------------- > Arlo Carreon > @mexitek > > -- > 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