A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://webplatform.github.io/docs/javascript/String/localeCompare below:

localeCompare ยท WebPlatform Docs

localeCompare Summary

Determines whether two strings are equivalent in the current locale.

Syntax
stringVar.localeCompare( stringExp )
stringVar
Required. A String object or string literal.
stringExp
Required. String to compare to stringVar.
Examples

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 Attributions

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