+ 3
How to create an array?
6 Respuestas
+ 5
var fruits=["red","green","blue"];
alert(fruits[0]);
+ 4
var arr = ["hello","world"];
+ 4
var arr = new Array("a", "b", "c");
+ 1
var array = new Array("1", "2");
0
You can use new Array( ) but everyone on the web recommends the literal [ ] : var a = [ ] //creates an empty array as well.
The reason being 'new Array()' is ambiguous and inconsistent and especially for developers from other languages very confusing. The performance gain is so minor and not even guaranteed depending on the browser.
So you are advised to initialize your arrays with [].
0
excuse me how do do the other create array with
document.write(example );