Home »
MCQs »
JavaScript MCQs
What is the output of the following JavaScript code? | Question 24
81. What will be the output of the following JavaScript code?
<script>
let x = "10";
let y = + x;
document.write(typeof y);
</script>
- string
- object
- undefined
- number
Answer: D) number
Explanation:
In JavaScript, the unary + operator can be used to convert a variable to a number. Hence, the statement let y = + x; will convert variable to number.