Back to basics for me :-( JS and array pains!!

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Back to basics for me :-( JS and array pains!!

Post by Chris Corbyn »

This is me, asking a noob question!!!

Why does this not work??

I just want to add stuff to my array without specifying a key :cry:

Code: Select all

var somearray = new Array();
somearrayї] = 'some value';
somearrayї] = 'another value';

//This also fails
somearray += 'added value';
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

those never worked that I'm aware of.. You're thinking php on the first part, and += works on strings, not arrays.

Code: Select all

var arr = new Array();
arr.push('some data');
arr.push('some more data');
http://devguru.com/Technologies/ecmascr ... array.html
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post by Chris Corbyn »

LOL... I knew I was being stupid.

BTW... I have something nice coming along that I will be posting in snippets soon :wink:
Post Reply