Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All

localeCompare Method (JavaScript)

Returns a value indicating whether two strings are equivalent in the current locale.



Required. A String object or literal.


Required. String to compare to stringVar.

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.

Supported in the following document modes: Quirks, Internet Explorer 6 standards, Internet Explorer 7 standards, Internet Explorer 8 standards, Internet Explorer 9 standards. See Version Information.

Applies To: String Object (JavaScript)

© 2015 Microsoft