Array value setting in javascript
- by Dennis
Hello. Again I'm still new to this javascript thing, so just would like to know if there is another way of setting the values of an array (just like declaring it);
//correct way of declaring an array and reusing
var adata = new Array('1','2','3');
//reusing of variable
adata[0] = '4';
adata[1] = '5';
adata[2] = '6'
**
This part is my question; I want to declare the values of the array just like declaring them to minimize the number of lines;
//array declaration
var data = new Array('1','2','3');
//reusing of variable
data = ['4','5','6']; --- (as an example) I get an error msg "Invalid assignment left-hand side"
is this possible? If so, what is the correct syntax? I hope I'm making sense.
Thanking you in advance.