June
27th,
2017
Normally, JavaScript strings are primitive values, created from literals: var firstName = “John”
But strings can also be defined as objects with the keyword new: var firstName = new String(“John”)
Don’t create strings as objects. It slows down execution speed. The new keyword complicates the code. This can produce some unexpected results:
Comparison:
Even worse: