Skip to content

Glossary: JavaScript Basics

localeCompare

A string method that returns a negative number, 0 or a positive number, as `sort` expects, and handles capitals and accents sensibly. It's used to sort objects by a text property.

Where the book teaches it

Related terms

Compare functionsort / toSorted