Return to Snippet

Revision: 56221
at March 16, 2012 20:18 by davidwaterston


Initial Code
if (typeof String.prototype.contains != 'function') {
    String.prototype.contains = function(str) {
        return this.indexOf(str) >= 0;
    };
}

Initial URL

                                

Initial Description
A simple Javascript function to determine if one string contains another.

Usage:

if (myString.contains("anything") { 
    do something… 
}

Initial Title
Case-sensitive 'contains'

Initial Tags

                                

Initial Language
JavaScript