Single Choice Easy

QWhat is the result of the following JavaScript code?

<p id="demo"></p>
<script>
function myFunction() 
{
   var num = 098;
   var n = num.valueOf()
   document.getElementById("demo").innerHTML = n;
}
</script>

ID: #5248 Javascript Graphics and Rendering MCQ 164 views
Question Info
#5248Q ID
EasyDifficulty
Javascript Graphics and Rendering MCQTopic

Choose the Best Option

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

  • A 098
  • B 98
  • C Error
  • D Undefined
Correct Answer

Explanation

The function valueOf() { [native code] }() method returns a number's primitive value.
In the preceding example, the value of num would be 98.

Share This Question

Challenge a friend or share with your study group.