- A var str = new String("Hello World!");
- B var str = String("Hello World!");
- C var str = "Hello World!";
- D var str = 'Hello World!';
- Share this MCQ
Answer:
A
Share this MCQ
While A, D, and E are all valid ways to create a new string in JavaScript,
using the "new" keyword and the String constructor function (as in C) is not recommended,
because it can cause confusion with the primitive string data type.
It is better to use either of the other options.
Share this MCQ