JSFiddle - React, Tailwind, and code Playground

by Andrew Gerst

HTML

See console.

A little reminder to myself of why I use object literal notation [] instead of new Array().

JavaScript

console.log("Create example arrays using array literal notation");
var b1 = [10, 30];
console.dir(b1);
var b2 = [10];
console.dir(b2);
var b3 = ["ten"];
console.dir(b3);
var b4 = [10.2];
console.dir(b4);

console.log("Create the same arrays using new Array");
var a1 = new Array(10, 30);
console.dir(a1);
var a2 = new Array(10);
console.dir(a2);
var a3 = new Array("ten");
console.dir(a3);
try {
    var a4 = new Array(10.2);
    console.dir(a4);
} catch (ex) {
    console.log(ex);
}