Compare
Checks equality of two strings.
compare
Section titled “compare”Performs a case-sensitive strict comparison between two strings.
Parameters
Section titled “Parameters”str1
:string
- The first string for comparison.str2
:string
- The first string for comparison.
Returns: boolean
Section titled “Returns: boolean”- Returns true if the strings are equal; otherwise, false.
function compare(str1: string, str2: string): boolean
compare('hello', 'hello') // true
compare('abc', 'ABC') // false
looseCompare
Section titled “looseCompare”Performs a case-insensitive loose comparison between two strings.
Parameters
Section titled “Parameters”str1
:string
- The first string for comparison.str2
:string
- The first string for comparison.
Returns: boolean
Section titled “Returns: boolean”- Returns true if the strings are equal (case-insensitive); otherwise, false.
function looseCompare(str1: string, str2: string): boolean
looseCompare('CAps', 'caPS') // true
looseCompare('abc', '123') // false