I took a JS course on a website , and in one of the lessons there was a piece Of code that did not make sense to me :

the code is in the picture , why str1 is less then str2 ?
Strings are compared based on standard lexicographical ordering, using Unicode values. That means "a" < "b" and "c" > "b"
Two strings are strictly equal when they have the same sequence of characters, same length, and same characters in corresponding positions. source
var str1 = "aardvark";
var str2="beluga";
console.log(str1 < str2);//true
console.log(str1.length < str2.length);//false
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With