/

HTML / CSS / JavaScript Tutorial

JavaScript String method: localeCompare()

[this page | pdf | back links]

The localeCompare() method (when applied to a JavaScript string) number which is -1 if string is before specified (compare) string in ascending sort order, 0 if they are the same and +1 if string is after specified string in ascending sort order. It is case-sensitive.

 

It has the following syntax with the following parameters:

 

string.localeCompare(comparestring)

 

Parameter

Required / Optional

Description

comparestring

Required

String to be searched for

 


NAVIGATION LINKS
Contents | Prev | Next | JavaScript String Variables


Desktop view | Switch to Mobile