LearnFrenzy
Sign in Take a free test

Strings · JavaScript Strings MCQ · Question 8

String(x) vs x.toString() Answer, explanation & discussion

  • MCQ
  • Medium
  • 0 comments
  • Answer explained
  • Moderated community
Question 8 Back to Exercise

Which conversion works when the value may be null?

  • A value.toString()
  • B String(value) Correct
  • C value.valueOf()
  • D value + toString
Correct Answer: Option B

String(null) is "null". null and undefined have no methods, so null.toString() throws a TypeError.

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!

Post your comment

Comments appear after a quick review by our team.

Search LearnFrenzy

Esc

Quick links