Robert Rocha Robert Rocha - 1 year ago 107
Javascript Question

What does .equals() do?

I saw the use of an

method in a Stackoverflow posting:

Any way to make jQuery.inArray() case insensitive?

var matchString = "MATCHME";
var rslt = null;
$.each(['foo', 'bar', 'matchme'], function(index, value) {
if (rslt == null && value.toLowerCase().equals(matchString.toLowerCase())) {
rslt = index;
return false;

Yet I cannot find any documentation on this method. Any references would help.

Answer Source

The code that you've seen in that other answer is not standard JS code.

It must have been lifted from a page that includes other code that adds the .equals() method to the String class (e.g. the "Processing.js" library) with code such as:

String.prototype.equals = function(that) {
    return this === that;

I've corrected the original answer so that it no longer has that dependency.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download