0
Can anyone explain me this Javascript output?
console.log("2" < "12') // false
1 Resposta
+ 10
Because "2" and "12" are both string,
When comparing string,
the charcodes of first characters are compared first
because the charcode of "2" is larger than the charcode of "1",
so "2" < "12" is false.
Get charcode with charcodeAt :
https://www.sololearn.com/post/143486/?ref=app
More detailed explanation by Omkar :
https://www.sololearn.com/post/254575/?ref=app
https://code.sololearn.com/WKKkpq0efxai/?ref=app