JavaScript MCQ Javascript Data Types MCQ Question #4882
Single Choice Easy

QWhich of the following is not a valid way to create a new number in JavaScript?

ID: #4882 Javascript Data Types MCQ 180 views
Question Info
#4882Q ID
EasyDifficulty
Javascript Data Types MCQTopic

Choose the Best Option

Click any option to instantly check if you're correct.

  • A var num = 10;
  • B var num = Number(10);
  • C var num = new Number(10);
  • D var num = 10.5;
Correct Answer

Explanation

While A, B, D, and E are all valid ways to create a new number in JavaScript, using the "new" keyword and the Number constructor function (as in C) is not recommended,
because it can cause confusion with the primitive number data type.
It is better to use either of the other options.

Share This Question

Challenge a friend or share with your study group.