You should always prefer literals over constructors.
This is not related to your question, but here is an example with arrays. new Array() can be confusing at a glance if you don't know how this works:
var a = [5,6]; var b = [5];
both create arrays of length 2 and 1, respectively. But consider
var a = new Array(5,6); var b = new Array(5);
The former creates an array of length 2 containing elements 5 and 6, the latter creates an array of empty length 5.
So you see, using literal notation, avoids this trap.
In addition, a literal designation is always used. When you create a string, you also write var t = "Hello world" , not var t = new String("Hello world") .
source share