I heard it was possible in Javascript to add a method to object types. So I tried adding a method to the Array type, like so:
Code:
Array.prototype.contains = function(elem) {
for(i in this) {
if(elem == this[i]) { return true; }
}
return false;
};
...for seeing if an element exists in this array. But whenever I insert this into my code, even without actually using it, it somehow messes up the parsing of the script and causes another function in another part of the script not to be recognized. Do I have the syntax wrong, here?