[JSMentors] Namespacing/Module Pattern: Why avoid overwriting an existing object?

2011-06-20 Thread Philip Schweiger
In reading about the JavaScript namespacing or module patterns, I often see a step taken to avoid overwriting an existing object. For instance, at Eric Miragla's description of the module pattern (http:// www.yuiblog.com/blog/2007/06/12/module-pattern/), he mentions that the YAHOO.namespace()

[JSMentors] Re: Parameters vs. Objects as Parameters

2011-06-20 Thread Jason Mulligan
carefully On Jun 20, 2:26 pm, Sidney San Martín s...@sidneysm.com wrote: To an extent, I agree… but how would you write a function like jQuery.ajax, which takes upwards of 30 optional parameters, in a more JavaScripty way? On Mon, Jun 20, 2011 at 2:07 PM, Jason Mulligan

[JSMentors] Re: Parameters vs. Objects as Parameters

2011-06-20 Thread Jason Mulligan
to elaborate, there's no reason why a parameter can't be an object containing optional parameters. On Jun 20, 2:26 pm, Sidney San Martín s...@sidneysm.com wrote: To an extent, I agree… but how would you write a function like jQuery.ajax, which takes upwards of 30 optional parameters, in a more

Re: [JSMentors] Parameters vs. Objects as Parameters

2011-06-20 Thread Sidney San Martín
Not exactly. You'd replace `foo` with the `argment()`ed version, and then this: foo({ a: 'one', c: 'three' }); become equivalent to calling the original like this: foo('one', undefined, 'three'); It's just a wrapper to make writing functions which take options easier. So instead of

[JSMentors] Re: Parameters vs. Objects as Parameters

2011-06-20 Thread RobG
On Jun 21, 4:07 am, Jason Mulligan attac...@gmail.com wrote: Considering the language, sending an object of args is going against the convention of JavaScript due to laziness. You've lost me. Are you saying passing an object is lazy? -- Rob -- To view archived discussions from the original