Created
December 2, 2012 21:05
-
-
Save davidwaterston/4191070 to your computer and use it in GitHub Desktop.
Javascript: Case-sensitive 'contains'
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| if (typeof String.prototype.contains != 'function') { | |
| String.prototype.contains = function(str) { | |
| return this.indexOf(str) >= 0; | |
| }; | |
| } |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
A simple Javascript function to determine if one string contains another.
Usage:
if (myString.contains("anything") { do something… }