JavaScript has arrays. What's lacking from the arrays that makes them unusable to you?So the first thing I see is I don't think javascript has an arraylist.
Originally posted by Bear Bibeault:
JavaScript has arrays. What's lacking from the arrays that makes them unusable to you?
[ June 13, 2008: Message edited by: Bear Bibeault ]
Originally posted by Eric Pascarello:
You do not have to declare the length with JavaScript arrays
Eric
Current best-practice eschews the new keyword on Javascript primitives. If you want to create a new Array simply use brackets [] like this�
Originally posted by Michael Hubele:
I found this on a website
var badArray = new Array(10); // Creates an empty Array that's sized for 10 elements.
var goodArray= [10]; // Creates an Array with 10 as the first element.
Hogwash. Either way is valid. I tend to use the [] notation myself and can't remember the last time I used the constructor, but that doesn't make using the Array construct a "bad practice".So they say that you should not use the "new" keyword due to best-practices
If this is true then how do I limit my array down to 2?
An array can take any number of entries regardless of how it is created.I need an array that can take any amount of of items(what this [] thing can do) however
That completely contradicts your previous statement. in any case, that isn't going to happen. If you don't want it to have more than two entries, don't give it more than two.I still want to have an array that only can have 2 fields and can't add onto it.
Nope. See above.My second array should never have more then 2 fields. If it is trying to add more then 2 fields then I rather have an expection thrown then it going on its merry way.
If you need a construct with only two entries, why use an array? Why not an Object with two properties?
I'm not sure where the "two" is coming from. It seems to me there'd be as many as there are clicked checkboxes. Why only 2?Originally posted by Michael Hubele:
After those have been put in that array. I am going to have another array that will insert that newly created array with the 2 cells.
Java will do the same, but JavaScript is not C# and not Java (despite its unfortunate name).Like I guess I am just use to C# where when you make an array you give it a size and if you go past that many cells it will throw and out of bounds exception.
If you have two items of data to store, an array with 2 entries isn't the best choice.I am not sure what you mean with this.
f you need a construct with only two entries, why use an array? Why not an Object with two properties?
I'm not sure where the "two" is coming from. It seems to me there'd be as many as there are clicked checkboxes. Why only 2?
That's kinda Lame. Rather:
var name = { first: 'Bear', last" 'Bibeault');
Originally posted by Michael Hubele:
Hmm I never seen this before. What is this called?