0 votes
in JavaScript by

Find out the correct output of the following given piece of code from the given options:

functionfun()  

{  

int y=10;  

char z=10;  

if(y.tostring()===z)  

returntrue;  

else  

returnfalse;  

}  

a) logical error

b) false

c) runtime error

d) true

1 Answer

0 votes
by

Answer: D

Reason: We can convert a non-string "integer " into a string by using the ".tostring()" method. The "===" (or we can say strict comparison) results in true only when, the content and the data-type of the operands are the same. So that's why the output of the above-given code will be obtained as true.

Related questions

0 votes
asked Mar 23, 2021 in JavaScript by sharadyadav1986
+1 vote
asked Mar 22, 2021 in JavaScript by Robindeniel
...