Difference between revisions of "JavaScript prototype"
From Wiki @ Karl Jones dot com
Karl Jones (Talk | contribs) (Created page with "In JavaScript, a prototype is a property of objects == Description == All objects in JavaScript are descended from Object; all objects inherit methods and properties fro...") |
Karl Jones (Talk | contribs) (→External links) |
||
Line 15: | Line 15: | ||
* [http://sporto.github.io/blog/2013/02/22/a-plain-english-guide-to-javascript-prototypes/ A Plain English Guide to JavaScript Prototypes] | * [http://sporto.github.io/blog/2013/02/22/a-plain-english-guide-to-javascript-prototypes/ A Plain English Guide to JavaScript Prototypes] | ||
* [http://javascriptissexy.com/javascript-prototype-in-plain-detailed-language/ JavaScript Prototype in Plain Language] | * [http://javascriptissexy.com/javascript-prototype-in-plain-detailed-language/ JavaScript Prototype in Plain Language] | ||
+ | * [http://yehudakatz.com/2011/08/12/understanding-prototypes-in-javascript/ Understanding "Prototypes" in JavaScript] | ||
+ | |||
[[Category:JavaScript]] | [[Category:JavaScript]] |
Revision as of 12:11, 11 November 2016
In JavaScript, a prototype is a property of objects
Description
All objects in JavaScript are descended from Object; all objects inherit methods and properties from Object.prototype, although they may be overridden (except an Object with a null prototype, i.e. Object.create(null)). For example, other constructors' prototypes override the constructor property and provide their own toString() methods.
Changes to the Object prototype object are seen by all objects through prototype chaining, unless the properties and methods subject to those changes are overridden further along the prototype chain. This provides a very powerful although potentially dangerous mechanism to override or extend object behavior.