What will be the output of the following JavaScript code? [code] function compare() { int num=2; char b=2; if(a==b)

What will be the output of the following JavaScript code?
Code:
function compare()
{
    int num=2;
    char b=2;
    if(a==b)
        return true;
    else
        return false;
}
A. true
B. false
C. runtime error
D. compilation error
 
Answer: a
Explanation: The == convert different type of operands to the same type before making the comparison. A strict comparison results into true value if the operands are of the same type and the contents match.
 

Tìm kiếm

Back
Top