Modifying Built-In Objects

  • JavaScript lets you modify built-in objects and data types
  • Can add new array or string methods for instance
  • Originally this was possible / somewhat common
  • Became less popular. Hurts standards adoption
"abc".reverse() // Throws error
String.prototype.reverse = function() { 
    return this.split("").reverse().join("")
}
"abc".reverse() // "cba"

8 / 24