JSFiddle - React, Tailwind, and code Playground
by Chuan Shao
JavaScript
var o = [42, "Sample Text", {x:88}];//JavaScript array is un-typed.
console.log(o);//[42, "Sample Text", Object {x=88}]
o[3] = 27;//JavaScript array is dynamic.
console.log(o);//[42, "Sample Text", Object {x=88}, 27]
o[5] = 99;//JavaScript array is sparse.
console.log(o);//[42, "Sample Text", Object {x=88}, 27, undefined, 99]
var a = [42, "Sample Text", {x:88}, 27, undefined, 99];
console.log(a);//[42, "Sample Text", Object {x=88}, 27, undefined, 99]
console.log(4 in o);//false
console.log(4 in a);//true
var x = [1,2,3,];//trailing comma will be omitted.
console.log(x.length);//3
var y = [1,,3];//member can be missed.
console.log(y);//[1, undefined, 3]
console.log(1 in y);//false
console.log(y.length);//3
var z = new Array(10);//pre-allocate memory, but no index is defined yet.
console.log(3 in z);//false
var m = new Array(42, 33, 99, "test", {k:99});
console.log(m);//[42, 33, 99, "test", Object {k=99}]