SitePoint Sponsor |
|
User Tag List
Results 1 to 5 of 5
-
Dec 8, 2006, 14:50 #1
- Join Date
- Jul 2003
- Location
- San Francisco
- Posts
- 127
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Passing variable-length argument list from one function to another
Given the following code:
Code:var xf2; function f1() { if (document.createElement && document.body && document.body.appendChild) { xf2 = new f2(arguments[]); } }
How do I pass the variable-length arguments list received by f1 on to f2?
-
Dec 8, 2006, 15:57 #2
- Join Date
- Jan 2005
- Location
- Too far up north
- Posts
- 1,566
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
You just wanna pass the arguments length to f2? or all the arguments?
-
Dec 8, 2006, 17:18 #3
- Join Date
- Jul 2003
- Location
- San Francisco
- Posts
- 127
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
I want to pass all the arguments, exactly as they came into f1
-
Dec 8, 2006, 21:59 #4
- Join Date
- Apr 2006
- Posts
- 802
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
This is simplest, but f2 has to take apart the single argument that is
passed it as an object:
function f1(){
if(whatever is true)xf2=new f2(arguments)
}
function f2(arg){
use arg as if it were arguments
var L=arg.length;
if arg[2];
whatever
}
-
Dec 12, 2006, 19:56 #5
- Join Date
- Jul 2003
- Location
- San Francisco
- Posts
- 127
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Thanks. Confirmed it works.
Bookmarks