Opens in a new tab
A picture of Jeff Brigman
I CODE TODAY FOR
A BETTER TOMORROW

Glossary Term

String.prototype.localeCompare()

2 tags 1 category

The localeCompare() method of String values returns a number indicating whether this string comes before, or after, or is the same as the given string in sort order. In implementations with Intl.Collator API support, this method delegates to Intl.Collator.

When comparing large numbers of strings, such as in sorting large arrays, it is better to create an Intl.Collator object and use the function provided by its compare() method.

Returns an integer indicating whether the referenceStr comes before, after or is equivalent to the compareString.

Negative when the referenceStr occurs before compareString Positive when the referenceStr occurs after compareString Returns 0 if they are equivalent

Syntax example: localeCompare(compareString)

Term Connections

Explore related terms connected by shared tags, shared categories, and relationship phrases. This map loads only when it comes into view.

Loading term connections…