The correct way to write a JavaScript array is:
[ 1, 2, 3 ]
.For example, this array
has 5
at index 0
and 10
at index 1
:
const array = [ 5, 10 ];
console.log(array.length); // 2
console.log(array[0]); // 5
console.log(array[1]); // 10
And this array
has "Hello"
at index 0
, false
at index 1
and 55
at index 2
:
const array = [ "Hello", false, 55 ];
console.log(array.length); // 3
console.log(array[0]); // Hello
console.log(array[1]); // false
console.log(array[2]); // 55