Tuesday, June 4, 2024
 Popular · Latest · Hot · Upcoming
100
rated 0 times [  104] [ 4]  / answers: 1 / hits: 96815  / 12 Years ago, mon, april 30, 2012, 12:00:00

I know the title is vague but I didn't know what to write.

In javascript, I know how to write functions that will be called like this :



argument1.function(argument2);


Here is the fiddle demonstration : http://jsfiddle.net/rFXhf/

Now I wonder if I can do :



argument1.argument2.function(argument3);//And even more!

More From » object

 Answers
11

you need to define the objects like this :



var argument1 = {
myvar : 12,
mymethod : function(test) { return something; }
}


then call mymethod like:



argument1.mymethod(parameter);


or the deeper version :



var argument1 = {
argument2 : {
mymethod : function(test) { return something; }
}
}


then:



argument1.argument2.mymethod(parameter);

[#85894] Friday, April 27, 2012, 12 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
allans

Total Points: 336
Total Questions: 120
Total Answers: 119

Location: Peru
Member since Mon, Jun 6, 2022
2 Years ago
;