JavaScript Literal shorthands, object array and regex

There are no classes in JavaScript, only objects.

You can use following shorthand to create object.

var obj = new Object();

But you can forget var obj = new Object();

Use {}

var obj = {};

Similar no need to use var arr = new Array();

var arr = []; looks more compact.

You can even use var regex = new RegExp('something'); alternative:

var regex = /something/;

tags: & category: -