Last active
August 29, 2015 13:58
-
-
Save z-------------/10014252 to your computer and use it in GitHub Desktop.
Adds an Array function to test if an array contains a particular value
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
| Array.prototype.contains = function(q){if(this.indexOf(q) != -1){return true}else{return false}} | |
| //["waffles",3.14,"pie"].contains(3.14) --> true | |
| //["waffles",3.14,"pie"].contains("foo") --> false |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment