[strings] localeCompare

This commit is contained in:
aruseni 2019-07-08 02:20:30 +03:00 committed by GitHub
parent 5e9eca374f
commit ea84ecf515
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -538,11 +538,11 @@ Luckily, all modern browsers (IE10- requires the additional library [Intl.JS](ht
It provides a special method to compare strings in different languages, following their rules.
The call [str.localeCompare(str2)](mdn:js/String/localeCompare):
The call [str.localeCompare(str2)](mdn:js/String/localeCompare) returns an integer indicating whether `str` comes before, after or is equivalent to `str2` according to the language rules:
- Returns `1` if `str` is greater than `str2` according to the language rules.
- Returns `-1` if `str` is less than `str2`.
- Returns `0` if they are equal.
- Returns a negative number if `str` is less than `str2`, i.e. `str` occurs before `str2`.
- Returns a positive number if `str` is greater than `str2`, i.e. `str` occurs after `str2`.
- Returns `0` if they are equivalent.
For instance: