By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,200 Members | 1,703 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,200 IT Pros & Developers. It's quick & easy.

converting arguments to an Array instance

P: n/a
There seem to be some options for converting the arguments object
inside a function to an instance of Array. I'm curious if anyone has
encountered any problems with any particular techniques for this

From <URL: http://groups.google.com/group/comp.lang.javascript/msg/98c27152ea5c7d55?dmode=source>

var args = [].slice.call(arguments,1);
var args = Array.prototype.slice.call(arguments, 1);

I've tried the following which is short and it seems to work in NN4.08
and O5.02. (I can't seem to keep a stable IE5.5. grrr.)

Array.apply([], arguments)

Thanks,
Peter
Dec 4 '07 #1
Share this Question
Share on Google+
5 Replies


P: n/a
On Dec 4, 11:48 am, Peter Michaux <petermich...@gmail.comwrote:
There seem to be some options for converting the arguments object
inside a function to an instance of Array. I'm curious if anyone has
encountered any problems with any particular techniques for this

From <URL:http://groups.google.com/group/comp.lang.javascript/msg/98c27152ea5c7...>

var args = [].slice.call(arguments,1);
var args = Array.prototype.slice.call(arguments, 1);

I've tried the following which is short and it seems to work in NN4.08
and O5.02. (I can't seem to keep a stable IE5.5. grrr.)

Array.apply([], arguments)
I thought that IE prior to 5.5. didn't have Function.prototype.call or
apply. You may want to implement your own native javascript version
where it is missing.

<URL:
http://groups.google.com.au/group/co...e0f921fe3043d0
>
A method that has been discussed before[1] is to augment
Object.prototype with the particular methods you are after, e.g.:

Object.prototype.join = Array.prototype.join;

But that may not be suitable. :-)
1. <URL:
http://groups.google.com.au/group/co...438840d6b5212e
>

--
Rob
Dec 4 '07 #2

P: n/a
On Dec 3, 6:53 pm, RobG <rg...@iinet.net.auwrote:
On Dec 4, 11:48 am, Peter Michaux <petermich...@gmail.comwrote:
There seem to be some options for converting the arguments object
inside a function to an instance of Array. I'm curious if anyone has
encountered any problems with any particular techniques for this
From <URL:http://groups.google.com/group/comp.lang.javascript/msg/98c27152ea5c7...>
var args = [].slice.call(arguments,1);
var args = Array.prototype.slice.call(arguments, 1);
I've tried the following which is short and it seems to work in NN4.08
and O5.02. (I can't seem to keep a stable IE5.5. grrr.)
Array.apply([], arguments)

I thought that IE prior to 5.5. didn't have Function.prototype.call or
apply.
Indeed. I will have to reinstall Windows and IE 5.5 to check IE 5.5's
behavior :-/

It does work in IE6.

You may want to implement your own native javascript version
where it is missing.

<URL:http://groups.google.com.au/group/co...browse_frm/thr...

A method that has been discussed before[1] is to augment
Object.prototype with the particular methods you are after, e.g.:

Object.prototype.join = Array.prototype.join;

But that may not be suitable. :-)

1. <URL:http://groups.google.com.au/group/co...browse_frm/thr...
My eyes are burning!
Peter
Dec 4 '07 #3

P: n/a
Peter Michaux wrote:
On Dec 3, 6:53 pm, RobG <rg...@iinet.net.auwrote:
>I thought that IE prior to 5.5. didn't have Function.prototype.call or
apply.
Indeed. I will have to reinstall Windows and IE 5.5 to check IE 5.5's
behavior :-/
Peter
No need to. You can use a free Windows image from Microsoft with Virtual
PC. I use VPC and have images for all the OS/IE combinations from
Win95/IE4.0 right up to XP/IE7.
Dec 4 '07 #4

P: n/a
Peter Michaux wrote:
I've tried the following which is short and it seems to work in NN4.08
and O5.02. (I can't seem to keep a stable IE5.5. grrr.)
Again, using VPC helps you keep a stable IE5.5 because you can discard
any Windows updates that might have happened during your session.

I have to wonder why you're putting effort into support NN4.08. That
browser is only going in one direction, and that's down the rankings of
popularity. There can't be more than a couple of thousand people in the
world still using it, and I bet all of them work in the QA departments.
I know of so many major sites (and I deal with a lot of them) that
simply re-route IE4 and NN4 to an unsupported page. You must have a good
bit of code that's unique to NN4 (I remember when I still had to support
it) and that's a very small audience that's demanding it.

It's time the web stopped putting a disproportionate amount of effort in
to support browsers that have < 0.01% market share (that's 1 in 10,000).
We'll only make those people upgrade by grinding them down (if indeed
there are any people outside of QA and automated test-suites still using
it seriously).
Dec 4 '07 #5

P: n/a
RobG wrote:
On Dec 4, 11:48 am, Peter Michaux <petermich...@gmail.comwrote:
>Array.apply([], arguments)

I thought that IE prior to 5.5. didn't have Function.prototype.call or
apply. [...]
I can confirm this, and I updated the ECMAScript Support Matrix accordingly:

http://PointedEars.de/es-matrix

Satisfying popular demand, I have modified the style sheet so that the
relation between the rows of each table are more obvious now. Hope you like
it. (If you like the table style of the German computer magazine c't [1], I
have added an alternative stylesheet for that as well.)
PointedEars
___________
[1] http://en.wikipedia.org/wiki/C%27t
Dec 5 '07 #6

This discussion thread is closed

Replies have been disabled for this discussion.