jPaq Docs - String.prototype.compareTo()

Quick Stats

Target Platforms:  PC (JScript) and the web (JavaScript)
Download Count:  750


Compares this string to another one.


  1. subject => String
    The string to compare this string to.
  2. [caseSensitive] => Boolean
    Optional. By default, this value false. The value which indicates whether or not the casing of the characters should influence the returned value.


Returns -1 if this string comes before subject, 1 if this string comes after subject, or 0 if this string is the same as subject.

Related Examples

  1. Case Insensitive Sort
    Have you ever had to sort an array in JavaScript?  With the built-in sort function, the task is usually pretty easy when it…