Connecting Tech Pros Worldwide Help | Site Map
Reply
 
LinkBack Thread Tools Search this Thread
  #1  
Old May 16th, 2008, 10:15 AM
Markus's Avatar
Moderator
 
Join Date: Jun 2007
Location: York, England, with wolves.
Age: 18
Posts: 2,976
Default Getting next free array index.

In php doing the below would assign the value to the next free index
[php]
// var $array has indices up to [7]
$array[] = "foo";

// $array[8] will now hold 'foo'
[/php]

Is there a way to do this in javascript?
Reply
  #2  
Old May 16th, 2008, 10:39 AM
hsriat's Avatar
Expert
 
Join Date: Jan 2008
Location: Bath, UK
Posts: 1,482
Default

Quote:
Originally Posted by markusn00b
In php doing the below would assign the value to the next free index
[php]
// var $array has indices up to [7]
$array[] = "foo";

// $array[8] will now hold 'foo'
[/php]

Is there a way to do this in javascript?
array.push('foo');

In PHP too, you can use array_push($array, "foo");
Reply
  #3  
Old May 16th, 2008, 11:00 AM
Markus's Avatar
Moderator
 
Join Date: Jun 2007
Location: York, England, with wolves.
Age: 18
Posts: 2,976
Default

Quote:
Originally Posted by hsriat
array.push('foo');

In PHP too, you can use array_push($array, "foo");
Cheers for that bro!
Reply
  #4  
Old May 16th, 2008, 11:04 AM
hsriat's Avatar
Expert
 
Join Date: Jan 2008
Location: Bath, UK
Posts: 1,482
Default

Quote:
Originally Posted by markusn00b
Cheers for that bro!
;)

good luck . . .
Reply
Reply

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Popular Articles

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over 205,248 network members.