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>
  1. string
  2. object
  3. undefined
  4. 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.

Comments and Discussions!

Load comments ↻






Copyright © 2024 www.includehelp.com. All rights reserved.