I’m studying JavaScript and this is a statement I came across:
new String("Hello");
This will create a new string that is the same as string literal "hello"
, although it will be classed as an object rather than a primitive values. For this reason it is preferable to use the string literal notation.
What is a String literal?
Why is new String("Hello")
classed as Object
?