Standard built-ins
Intl.Collator.prototype.compare()
Bound comparator returning a negative, zero or positive number; exact magnitude is not guaranteed.
Formal Syntax & Structure
javascript syntaxjavascript
collator.compare(a, b)Parameters & Attributes
| Name | Type | Description |
|---|---|---|
| a | String | First text. |
| b | String | Second text. |
Return Value
Number
Signed comparison result.
Working Example
Example Snippetjavascript
const c=new Intl.Collator("en-US",{numeric:true});console.log(c.compare("x2","x10")<0);