/    Sign up×
Community /Pin to ProfileBookmark

[RESOLVED] Function Arguments

I found the following and the original function [foo0()] works well

I tried to modify it and the second version [foo1()] doesn’t work worth a flip.
The error console complains that ‘argv.join’ is not a function.

Anybody have any idea what is different behind the logic of the functions? ?

[code=php]
<HTML>
<HEAD>
<SCRIPT Language=”JavaScript”>

function foo0() {
var argv = foo0.arguments;
var argc = argv.length;
var str = ‘Arguments: n’;
for (var i = 0; i < argc; i++) { str += i + ” = ” + argv[i]+’n’; }
alert(str);
}

function foo1() {
var argv = foo1.arguments;
var str = ‘Arguments: n’;
str += argv.join(‘|’);
alert(str);
}

</SCRIPT>
</HEAD>
<!– BODY onload=”foo(‘hello’, ‘world’);” –>
<BODY>
<button onClick=”foo0(‘p1′,’p2′,’p3’)”>Pass Params Orig</button>
<button onClick=”foo1(‘p1′,’p2′,’p3’)”>Pass Params Alt.</button>

</BODY>
</HTML>
[/code]

to post a comment
JavaScript

2 Comments(s)

Copy linkTweet thisAlerts:
@Orc_ScorcherAug 20.2007 — arguments is not a JavaScript array, it's a special object that doesn't have a join method. Also, functionName.arguments is outdated, simply use arguments without a prefix.
Copy linkTweet thisAlerts:
@JMRKERauthorAug 20.2007 — Thanks for information, both for the original question and the question not asked!

Appreciate the quick reply.
×

Success!

Help @JMRKER spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 4.29,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...