+ 8
I don't understand the result
Why the result is 0? 1 is a number and "1" is a string, or am I wrong? If (1 != "1") {document.write(1);} Else {document.write(0);}
4 ответов
+ 20
== is used to check two thing are equal in value but not in type so
1 == "1" will be true and
1 != "1" will be false
+ 5
It will print 0 bcoz 1!="1" false
+ 3
Coder I selected the best answer: isn't it enough?
+ 2
If you use === operator it would print 1. This compares only the value and not the type. This ia because there are no data types in javascript and to print 1 in this case only the === operator was added to js and not to java. Also this is only present in strongly typed languages i.e. those that have no type specification.