What is the output of the following code: console.log(typeof 42);?
a) “number”
b) “string”
c) “boolean”
d) “undefined”
Answer:
a) “number”
Explanation:
The typeof
operator is used to determine the data type of a given variable or value in JavaScript. In this case, 42
is a number, so the output is “number”.
Example:
console.log(typeof 42); // Output: "number"
console.log(typeof "Hello"); // Output: "string"
console.log(typeof true); // Output: "boolean"