Elementals.js

Latest Version: 3.7 Final 20 December 2018

Method _.Compare.string

Summary:

Compares two strings after normalizing them.

"Normalize" means that _.safeString() is called, which if the variable passed is null or undefined an empty string is returned, otherwise the result is trimmed of leading and trailing whitespace.

Calling Convention:
_.Compare.string(String, String)
Parameters:
String
Your strings to be normalized and compared.
Returns:
-1 if first string is alphabetically lower than the second
0 if the two strings are equal
1 if first string is alphabetically higher than the second

The various compare functions stored in elementals are meant as easy callbacks for use with _.USort.element.

Advertisement