MCQ Single Best Answer Not Set

QWhat is the result of the following code?
console.log(5 - '5');

ID: #4861 JavaScript Operator MCQ 269 views
Question Info
#4861Q ID
Not SetDifficulty
JavaScript Operator MCQTopic

Choose the Best Option

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

  • B '55'
  • C '0'
  • D '5'
Correct Answer: Option A

Explanation

The result of the code is 0 .
In JavaScript, the - operator performs subtraction if both operands are numbers. .
In this case, the string '5' is converted to the number 5, so the final result is 5 - 5 = 0..

Share This Question

Challenge a friend or share with your study group.