Question 9
Back to Exercise
Which statement about new String("hi") is true?
- A It is identical to the primitive "hi"
- B It throws a TypeError
- C It is an object: typeof gives "object" and it is not === "hi" Correct
- D It creates an array of characters
Correct Answer: Option C
Wrapper objects compare by reference and are always truthy (even new String("")). Use primitive strings; call String() without new to convert.
Discussion & Comments 0
Share your method, a shortcut, or ask about a step you didn't follow.
No comments yet. Be the first to share your solution!