Should I use "new" over literals?

I've read a lot of paragraphs about w3schools telling us to avoid "new" when there is another option. The "new" keyword is easy to use, so why are they telling us this? What are the benefits of using literals?

var family = [
new Person("Bob",13),
new Person("Bo0",103),
new Person("hfg",163),
new Person("timmy",6)
]

      

instead of this

var family = new Array();
family[0] = new Person("alice", 40);
family[1] = new Person("bob", 42);
family[2] = new Person("michelle", 8);

      

which one is better or wiser?

English is not my first language. Please correct errors if possible.

Thank.

+3


source to share





All Articles