Determines whether two strings are equivalent in the current locale.
SyntaxstringVar.localeCompare( stringExp )
The following code shows how to use localeCompare.
var str1 = "def";
var str2 = "abc"
document.write(str1.localeCompare(str2) + "<br/>");
var str3 = "ghi";
document.write(str1.localeCompare(str3)+ "<br/>");
var str4 = "def";
document.write(str1.localeCompare(str4));
Remarks
The localeCompare performs a locale-sensitive string comparison of the stringVar and the stringExp and returns -1, 0, or +1, depending on the sort order of the system default locale.
If stringVar sorts before stringExp , localeCompare returns -1; if stringVar sorts after stringExp , +1 is returned. A return value of zero means that the two strings are equivalent.
See also Other articles AttributionsMicrosoft Developer Network: Article
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4