Created
February 22, 2010 18:40
-
-
Save philhawksworth/311336 to your computer and use it in GitHub Desktop.
This file contains 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
Array.prototype.contains = function(item) { | |
return this.indexOf(item) != -1; | |
}; | |
var a = ['foo', 'bar', 'baz']; | |
alert(a.contains('bar')); | |
// Handy but arguably not always a good idea... | |
// String.prototype and Array.prototype are themselves global namespaces, and adding properties to them brings the same risk of collisions as being careless with regular globals... | |
// -- http://simonwillison.net/2007/Aug/15/jquery/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment