Skip to content

Compare

Checks equality of two strings.

Performs a case-sensitive strict comparison between two strings.

  • str1: string - The first string for comparison.
  • str2: string - The first string for comparison.
  • Returns true if the strings are equal; otherwise, false.
Definition
function compare(str1: string, str2: string): boolean
Examples
compare('hello', 'hello') // true
compare('abc', 'ABC') // false

Performs a case-insensitive loose comparison between two strings.

  • str1: string - The first string for comparison.
  • str2: string - The first string for comparison.
  • Returns true if the strings are equal (case-insensitive); otherwise, false.
Definition
function looseCompare(str1: string, str2: string): boolean
Examples
looseCompare('CAps', 'caPS') // true
looseCompare('abc', '123') // false