Standard built-ins

Intl.Collator.prototype.compare()

Try the free JavaScript compiler

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

NameTypeDescription
aStringFirst text.
bStringSecond 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);
JavaScript Reference