/ Published in: JavaScript
Expand |
Embed | Plain Text
Array.prototype.in_array = function(p_val) { for(var i = 0, l = this.length; i < l; i++) { if(this[i] == p_val) { return true; } } return false; } // Usage var foo = ["a", "b"]; foo.in_array("a"); // true foo.in_array("c"); // false
You need to login to post a comment.
