Use if statement with String.localeCompare
|
|
var oStringObject1 = new String("yellow"); var oStringObject2 = new String("brick"); var iResult = sTestString.localeCompare("brick");
if(iResult < 0) { alert(oStringObject1 + "comes before "+ oStringObject2); } else if (iResult > 0) { alert(oStringObject1 + "comes after "+ oStringObject2); } else { alert("The two strings are equal"); }
|
|
|
HTML code for linking to this page:
Related in same category :
-
-
-
-
|