Page 1 of 1

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

Posted: Sat Apr 02, 2005 10:38 am
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';

Posted: Sat Apr 02, 2005 10:46 am
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

Posted: Sat Apr 02, 2005 10:48 am
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: