1 | User-defined Methods |
2 | Methods may be added to objects: // Does an array contain element x ? function contains(x) { for (var i=0; i<this.length; i++) { if (this[i] == x) return true; } return false; } |
3 | Add the method to the Array object with the prototype property: Array.prototype.contains = contains; |