Difference between revisions of "JavaScript prototype"

From Wiki @ Karl Jones dot com
Jump to: navigation, search
(External links)
 
(One intermediate revision by the same user not shown)
Line 1: Line 1:
In [[JavaScript]], a prototype is a property of objects
+
In [[JavaScript]], '''prototype''' is a property of objects
  
 
== Description ==
 
== 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.
+
All objects in [[JavaScript]] are descended from <code>Object</code>; 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.
 
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.
Line 16: Line 16:
 
* [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]
 
* [http://yehudakatz.com/2011/08/12/understanding-prototypes-in-javascript/ Understanding "Prototypes" in JavaScript]
 
+
* [http://stackoverflow.com/questions/572897/how-does-javascript-prototype-work How does JavaScript .prototype work?]
 +
* [https://code.tutsplus.com/tutorials/prototypes-in-javascript--net-24949 Prototypes in JavaScript] @ code.tutsplus.com
  
 
[[Category:JavaScript]]
 
[[Category:JavaScript]]

Latest revision as of 12:13, 11 November 2016

In JavaScript, 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.

See also

External links