Mombu the Microsoft Forum sponsored links

Go Back   Mombu the Microsoft Forum > Microsoft > Array.push - Javascript
User Name
Password
REGISTER NOW! Mark Forums Read

sponsored links


Reply
 
1 16th March 07:10
hai
External User
 
Posts: 1
Default Array.push - Javascript



Hi all:
Does anyone know how to add a new element to an array.

myArray = new Array();
myArray.push("item1");


DOes anyone show me how Array is used to add a new element?

Thanks
Hai
  Reply With Quote


  sponsored links


2 16th March 07:10
name
External User
 
Posts: 1
Default Array.push - Javascript



var monkey = []


two monkeys are called a group of monkeys
that are not realizing that they proliferate.

Now use math:

monkey[monkey.length] = "another monkey with attitude A"
monkey[monkey.length] = "another monkey with zebra stripes"
monkey[monkey.length] = "another monkey with a beard"

-------------

Count the monkeys.

There are three or 3.

In academic length it is 2, counting 0 a number.

--------------------------

That is all there is to know.

If you can't count the monkeys, or think you are not among them,
you can always help yourself with 0.
  Reply With Quote
3 16th March 07:10
joe fawcett
External User
 
Posts: 1
Default Array.push - Javascript


Surprising that it doesn't, have you the latest version of JScript? Push was
added fairly recently.

Joe
  Reply With Quote
4 16th March 07:10
tim slattery
External User
 
Posts: 1
Default Array.push - Javascript


This will work fine. Since the subscript of the first element of the
array is zero, not one, array.length is always one greater than the
highest subscript. So monkey[monkey.length] points just beyond the
current length of the array. Javascript, being an interpreted
language, simply adds an element to the array.

--
Tim Slattery
MS MVP(DTS)
Slattery_T@bls.gov
  Reply With Quote
5 16th March 07:10
hai
External User
 
Posts: 1
Default Array.push - Javascript


Hi Joe:

I don't use JSscript but rather Javascript & VScript

Hai

Joe Fawcett" <joefawcett@hotmail.com> wrote in message news:eh9hJ$jwDHA.3216@TK2MSFTNGP11.phx.gbl...
  Reply With Quote
6 16th March 07:10
hg0180
External User
 
Posts: 1
Default Array.push - Javascript


Hello,
do you have the latest version with SP1 ?
I got problems with javascript and IE6 about half a year ago and it's
fixed in the actual version.I tried your script and it runs.

Heiko
  Reply With Quote
7 16th March 07:10
joe fawcett
External User
 
Posts: 1
Default Array.push - Javascript


If you use IE you use JScript, that's Microsoft's version of ECMAScript.
Netscape's version is called JavaScript.

As I said, this is quite a common problem. Make sure you have latest updates
etc.

--

Joe
  Reply With Quote
Reply


Thread Tools
Display Modes




Copyright © 2006 SmartyDevil.com - Dies Mies Jeschet Boenedoesef Douvema Enitemaus -
666