Skip to main content
Deno 2 is finally here 🎉️
Learn more
Module

x/ayonli_jsext/esm/string/index.js>compare

A JavaScript extension package for building strong and modern applications.
Latest
function compare
import { compare } from "https://deno.land/x/ayonli_jsext@v0.9.72/esm/string/index.js";

Compares two strings, returns -1 if a < b, 0 if a === b and 1 if a > b.

NOTE: prefer using String.prototype.localeCompare instead.

Examples

Example 1

import { compare } from "@ayonli/jsext/string";

console.log(compare("a", "b")); // -1
console.log(compare("b", "a")); // 1
console.log(compare("a", "a")); // 0

Parameters

str1
str2