By using
comparison operators (==, !=, <, <=, >, >=), you can compare
strings. Strings are compared in lexicographic order.
String
comparison is case-sensitive, so lower case letters are always greater than
upper case letters.
<!DOCTYPE html> <html> <head> <title>strings</title> </head> <body> <script type="text/javascript"> var str1 = "Hello"; var str2 = "hello"; var str3 = "World"; document.write("(str1 < str2): " + (str1 < str2) + "<br />"); document.write("(str1 < str3): " + (str1 < str3) + "<br />"); document.write("(str2 < str3): " + (str2 < str3) + "<br />"); </script> </body> </html>
No comments:
Post a Comment