+ 1
Help me compare two string of number javascript
why thel result is true Console.log("2">"12") // true I dont understand it
3 Answers
+ 4
Because in JavaScript strings comparison is according to the dictionary comparison. in this case, the first character of "2" is greater than the first character of "12" that's why it shows true.
+ 2
'2' > '1'
Like an alphabet
+ 1
Thanks!!