473,320 Members | 1,978 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,320 software developers and data experts.

converting arguments to an Array instance

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
5 1645
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
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
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Govind | last post by:
Hi All, I want to Convert 32 bit integers to byte in right alighed format . For 32 = the usual way is BitConverter.GetBytes(int32)==> xx xx 00 00 , but i want right aligned like 00 00 xx xx.Is...
4
by: jagmeena | last post by:
Hello, I am sure this problem has been addressed before, however, I could'nt get a suitable solution to my problem. Hence I am posting here. Thanks a lot for all your help. The code I have is ...
9
by: Matt Eberts | last post by:
Sorry, bad title. Anyway, is there a way to pass the arguments to an object instantiated via a constructor using the arguments object and have it expanded, so to speak, so that it doesn't appear as...
3
by: masood.iqbal | last post by:
In this day and age, you never say no to any work that is thrown at you ---- so when I was offered this short-term contract to convert legacy C code to C++, I did not say no. Personally I believed...
8
by: iyuen | last post by:
I'm having problems with converting a byte array to an image object~ My byte array is an picture in VB6 StdPicture format. I've used propertybag to convert the picture into base64Array format in...
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 +=...
7
by: sfeher | last post by:
Hi All, Is there a way to preserve the arguments across functions? I have: <script> function myFirstFunction() { // arguments = 'param1'
36
by: Pacific Fox | last post by:
Hi all, haven't posted to this group before, but got an issue I can't work out... and hoping to get some help here ;-) I've got a base object that works fine with named arguments when called...
9
by: mathieu | last post by:
Hi, I know I am doing something stupid here, but it's friday night and I cannot see what is the issue here: Thanks, -Mathieu #include <iostream>
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.