What is the output of the following JavaScript code? | Question 26

83. What will be the output of the following JavaScript code?

<script>
    let x = 10;
    
    document.write(x, " , ", toString(x));
</script>
  1. 10 , 10
  2. 10 , undefined
  3. 10 , [object Undefined]
  4. None of the above

Answer: C) 10 , [object Undefined]

Explanation:

In the above JavaScript code, the statement toString(x) will not convert number to string because toString() is not a global method, it is a Number method and the correct way is to call this function is x.toString().

Comments and Discussions!

Load comments ↻






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