MCQ Single Best Answer Easy

QWhat is the result of the following code?
var num = 10;
num = "Hello";
console.log(typeof num);
                    

ID: #4884 Javascript Data Types MCQ 162 views
Question Info
#4884Q ID
EasyDifficulty
Javascript Data Types MCQTopic

Choose the Best Option

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

  • A number
  • B string
  • C boolean
  • D undefined
Correct Answer: Option B

Explanation

In JavaScript, variables are dynamically-typed, which means that their type can change at runtime.
In this case, the variable num is initially assigned the value 10, which is a number.
However, on the second line, num is assigned the value "Hello", which is a string.
Therefore, the typeof operator will return "string" when it is called on num.

Share This Question

Challenge a friend or share with your study group.