GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing www.geeksforgeeks.org — JavaScript String localeCompare() Method - GeeksforGeeks JavaScript String localeCompare() MethodLast Updated : 11 Jun, 2026 The string.localeCompare() is an inbuilt method in JavaScript that is used to compare any two elements and returns a positive number if the reference string is lexicographically greater than the compare string and a negative number if the reference string is lexicographically smaller than the compare string and zero (0) if the compare and reference strings are equivalent. Syntax:referenceString.localeCompare(compareString);Parameters:Here the parameter compareString is a string with which the reference string is compared. Return Values:It returns a positive number if the reference string is lexicographically greater than the compare string and negative number if the reference string is lexicographically smaller than the compare string and zero (0) if the compare and reference strings are equivalent. Example 1: This example shows the basic use of the string.localeCompare() Method in Javascript, here we compare the strings based on the locale-specific sorting order and return -1 because "apple" comes before "banana" alphabetically.
Comment Explore |
| You are visitor 01402503 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |