The localeCompare() function of string object returns a number indicating whether a reference string comes before or after or is the same as the given string in sort order. Use it for example to check two strings are equivalent.
Syntax