0

Why I am getting the output false ?

console.log("2" < "12")

17th Aug 2019, 11:46 AM
Umesh Kushwaha
Umesh Kushwaha - avatar
5 Respostas
+ 5
JavaScript compares the strings according to their lexicographical (dictionary) order based on Unicode. The first character '2' is 'larger' than '1'. https://javascript.info/comparison
17th Aug 2019, 11:51 AM
Hatsy Rei
Hatsy Rei - avatar
+ 1
Thanks Hatsy.
17th Aug 2019, 11:57 AM
Umesh Kushwaha
Umesh Kushwaha - avatar
0
I think you are comparing strings (“”) and not integers
17th Aug 2019, 11:48 AM
Brave Tea
Brave Tea - avatar
0
Yes, but output should be true.
17th Aug 2019, 11:50 AM
Umesh Kushwaha
Umesh Kushwaha - avatar
0
I don’t really know that much about JS so why would that be true?
17th Aug 2019, 11:51 AM
Brave Tea
Brave Tea - avatar