I’m sure this question has been answered before, but I don’t think I’m using the right search phrase.
I think an example will explain better what I’m trying to ask:
var test = {};
test.example = function(parameter_2){
alert(parameter_1+parameter_2);
}
test("parameter_1").example("parameter_2");
Obviously that last line won’t work. Essentially wanting to do something like jQuery does with selectors, but just a little more archaic.
I’ll probably just pass both parameters into the example(p1,p2) function.
It just sort of sparked my curiosity.
I found this: http://enterprisejquery.com/2010/08/javascript-parameter-patterns-with-extend-and-beyond/ but I don’t think it quite answered my question.
A nonglobal way of doing what RueTheWhirled had said earlier:
Its the same basic idea, but it changes a local object instead.
A comment was posted above asking for a link on this (which I don’t have unfortunetly) but running the following snippet on this setup produces 4 and 6 as expected.