473,385 Members | 1,927 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

functions and arguments.length; passing unknown number of arguments

I'm going thru code and have never seen this before
http://www.webreference.com/programm...column2/3.html
Look at function CreateDragContainer() on line 25. It has no
arguments defined and depends on a function property named arguments
to process its input. I poked around and found this is deprecated.

How do you pass an unknown number of arguments to a function? Put
them in an array?

Thanks.
Sep 24 '08 #1
9 5239
oldyork90 <ol*******@yahoo.comwrites:
I'm going thru code and have never seen this before
http://www.webreference.com/programm...column2/3.html
Look at function CreateDragContainer() on line 25. It has no
arguments defined and depends on a function property named arguments
to process its input. I poked around and found this is deprecated.
Function.arguments is deprecated. The automically instantiated variable
arguments is not.
How do you pass an unknown number of arguments to a function? Put
them in an array?
I use the arguments variable.

--
Joost Diepenmaat | blog: http://joost.zeekat.nl/ | work: http://zeekat.nl/
Sep 24 '08 #2
SAM
Le 9/24/08 9:23 PM, oldyork90 a écrit :
>
How do you pass an unknown number of arguments to a function? Put
them in an array?
function hello() {
for(var i=0; i< arguments.length; i++) alert(arguments[i]);
}

hello('hello guy');
hello('hello','old boy');
hello('hello','Old Rock','the 90th');

var t1 = 'Hello';
var t2 = 'man';
hello(t1, t2);
Is there really necessary to put previously the arguments in an array ?
var or = ['hello','Old Rock','the 90th'];

function salut() {
arguments = arguments.length==1?
arguments[0].toString().split(',') : arguments;
for(var i=0; i< arguments.length; i++) alert(arguments[i]);
}

salut(or);

--
sm
Sep 24 '08 #3
Joost Diepenmaat wrote:
Function.arguments is deprecated. The automically instantiated variable
arguments is not.
>How do you pass an unknown number of arguments to a function? Put
them in an array?

I use the arguments variable.
`arguments' is a property of the Activation/Variable Object of a local
execution context, but not a variable. And no, that is not a contradiction :)
PointedEars
--
Prototype.js was written by people who don't know javascript for people
who don't know javascript. People who don't know javascript are not
the best source of advice on designing systems that use javascript.
-- Richard Cornford, cljs, <f8*******************@news.demon.co.uk>
Sep 26 '08 #4
Thomas 'PointedEars' Lahn <Po*********@web.dewrites:
Joost Diepenmaat wrote:
>Function.arguments is deprecated. The automically instantiated variable
arguments is not.
>>How do you pass an unknown number of arguments to a function? Put
them in an array?

I use the arguments variable.

`arguments' is a property of the Activation/Variable Object of a local
execution context, but not a variable. And no, that is not a contradiction :)
In the interest of academics; is there any way to tell the difference
using javascript code?

--
Joost Diepenmaat | blog: http://joost.zeekat.nl/ | work: http://zeekat.nl/
Sep 26 '08 #5
Joost Diepenmaat wrote:
Thomas 'PointedEars' Lahn <Po*********@web.dewrites:
>Joost Diepenmaat wrote:
>>Function.arguments is deprecated. The automically instantiated variable
arguments is not.

How do you pass an unknown number of arguments to a function? Put
them in an array?
I use the arguments variable.
`arguments' is a property of the Activation/Variable Object of a local
execution context, but not a variable. And no, that is not a contradiction :)

In the interest of academics; is there any way to tell the difference
using javascript code?
Quick hack for testing if `x' was declared a local variable:

/\bvar\s+([A-Za-z_$][\w$]*\s*,\s*)*x\b/.test(arguments.callee)

This should be adapted for Unicode-aware implementations, see ES3F 12.2 and
7.5.3.
PointedEars
--
Prototype.js was written by people who don't know javascript for people
who don't know javascript. People who don't know javascript are not
the best source of advice on designing systems that use javascript.
-- Richard Cornford, cljs, <f8*******************@news.demon.co.uk>
Sep 26 '08 #6
Thomas 'PointedEars' Lahn wrote:
Quick hack for testing if `x' was declared a local variable:

/\bvar\s+([A-Za-z_$][\w$]*\s*,\s*)*x\b/.test(arguments.callee)

This should be adapted for Unicode-aware implementations, see ES3F 12.2 and
7.5.3.
^^^^^
I meant the following section, 7.6 ("Identifiers"), of course.

Thank you and good night ;-)
PointedEars
--
var bugRiddenCrashPronePieceOfJunk = (
navigator.userAgent.indexOf('MSIE 5') != -1
&& navigator.userAgent.indexOf('Mac') != -1
) // Plone, register_function.js:16
Sep 26 '08 #7
On Sep 27, 1:12*am, Thomas 'PointedEars' Lahn <PointedE...@web.de>
wrote:
Joost Diepenmaat wrote:
Thomas 'PointedEars' Lahn <PointedE...@web.dewrites:
Joost Diepenmaat wrote:
Function.arguments is deprecated. The automically instantiated variable
arguments is not.
>>How do you pass an unknown number of arguments to a function? *Put
them in an array?
I use the arguments variable.
`arguments' is a property of the Activation/Variable Object of a local
execution context, but not a variable. *And no, that is not a contradiction :)
In the interest of academics; is there any way to tell the difference
using javascript code?

Quick hack for testing if `x' was declared a local variable:

* /\bvar\s+([A-Za-z_$][\w$]*\s*,\s*)*x\b/.test(arguments.callee)
Parsing the source ? come on ! That's not serious !

Try to see a bit further than your own nose. Activation objects are
notional entities. They could as well have called them 'magically
bound variables'.

--
Jorge.

Sep 26 '08 #8
Jorge wrote:
Thomas 'PointedEars' Lahn wrote:
>Joost Diepenmaat wrote:
>>Thomas 'PointedEars' Lahn <PointedE...@web.dewrites:
Joost Diepenmaat wrote:
Function.arguments is deprecated. The automically instantiated variable
arguments is not.
>How do you pass an unknown number of arguments to a function? Put
>them in an array?
I use the arguments variable.
`arguments' is a property of the Activation/Variable Object of a local
execution context, but not a variable. And no, that is not a contradiction :)
In the interest of academics; is there any way to tell the difference
using javascript code?
Quick hack for testing if `x' was declared a local variable:

/\bvar\s+([A-Za-z_$][\w$]*\s*,\s*)*x\b/.test(arguments.callee)

Parsing the source ? come on ! That's not serious !
If you have a better idea, then post it. If not, shut up.
Try to see a bit further than your own nose. Activation objects are
notional entities.
Whatever you might mean by "notional", Activation Objects exist and are part
of the scope chain of function code (ES3F, 10.2.3). Furthermore, "The
activation object is then used as the variable object for the purposes of
variable instantiation." (10.1.6) Unfortunately, the Activation/Variable
Object cannot be referred to, hence this quick hack.
They could as well have called them 'magically bound variables'.
You could as well be called an incompetent fool, but I will assume in your
favor you are just tired or drunk or both right now. So go to bed, please.
PointedEars
--
Prototype.js was written by people who don't know javascript for people
who don't know javascript. People who don't know javascript are not
the best source of advice on designing systems that use javascript.
-- Richard Cornford, cljs, <f8*******************@news.demon.co.uk>
Sep 27 '08 #9
On Sep 27, 3:58*am, Thomas 'PointedEars' Lahn <PointedE...@web.de>
wrote:
Whatever you might mean by "notional", Activation Objects exist and are part
of the scope chain of function code (ES3F, 10.2.3). *Furthermore, "The
activation object is then used as the variable object for the purposes of
variable instantiation." (10.1.6) *Unfortunately, the Activation/Variable
Object cannot be referred to, hence this quick hack.
And rest assured that nearly everything everywhere nowadays is
(internally) held in objects as well... and ? 'If it looks like a duck
and quacks like a duck, it must be a duck' : but this object of yours,
from a JS programmer point of view, not only doesn't quack like an
object, it doesn't even look like one because it's invisible. They
might have as well written the spec in another way using a different
language and you would not be here arguing about its existence. In
this sense it's 'notional only'.

--
Jorge.
Sep 27 '08 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Anthony Baxter | last post by:
To go along with the 2.4a3 release, here's an updated version of the decorator PEP. It describes the state of decorators as they are in 2.4a3. PEP: 318 Title: Decorators for Functions and...
66
by: Darren Dale | last post by:
Hello, def test(data): i = ? This is the line I have trouble with if i==1: return data else: return data a,b,c,d = test()
1
by: db2sysc | last post by:
All, We have listed out the INBUILT Function differences between Sybase and DB2. Kindly provide your feedback or corrections and for CHANGES - DO WE NEED TO CODE our own UDFs?
6
by: Melkor Ainur | last post by:
Hello, I'm attempting to build an interpreter for a pascal-like language. Currently, I don't generate any assembly. Instead, I just build an abstract syntax tree representing what I've parsed...
41
by: Telmo Costa | last post by:
Hi. I have the following code: -------------------------------------- function Tunnel() { //arguments(???); } function Sum() { var sum = 0; for (i=0; i<arguments.length; i++) sum +=...
15
by: Water Cooler v2 | last post by:
Can javascript functions have variable number of arguments - a concept known as paramarrays?
16
by: Martin Jørgensen | last post by:
Hi, Problem: ======== Some of my output functions are beginning to take pretty many arguments... I mean.... We're talking about 10-15 arguments :-) So I thought to myself, perhaps this is...
10
by: ConfusedAlot | last post by:
I am having difficulty defining the function prototypes and corresponding parameters when the function is called from main. Any help is greatly appreciated. //The database struct OpAmps { ...
18
by: squaretriangle | last post by:
Is it possible through some trickery, perhaps using the methods of stdarg, to pass a dynamic (unknown at compile time) number of arguments to a function? For example, I want to enumerate an array...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.