JavaScript: Difference between revisions

Content deleted Content added
Objects: Make prototype-based link direct
Line 50:
JavaScript has several kinds of built in objects, namely [[Array]], [[Boolean datatype|Boolean]], [[Date]], [[Function (programming)|Function]], [[Mathematics|Math]], [[Number]], [[Object (computer science)|Object]], [[regular expressions|RegExp]] and [[String#Mathematics and Computer Science|String]]. Other objects are "host objects", defined not by the language but by the runtime environment. For example, in a browser, typical host objects belong to the [[Document Object Model|DOM]] ([[window (computing)|window]], [[form (document)|form]], [[link]]s etc.).
 
By defining a [[constructor function]] it is possible to define objects. JavaScript is a [[prototype-based programming|prototype based]] object-based language. This means that inheritance is between objects, not between classes (JavaScript has no classes). Objects inherit properties from their prototypes.
 
One can add and remove properties or methods to individual objects after they have been created. To do this for all instances created by a single constructor function, one can use the <tt>prototype</tt> property of the constructor to access the prototype object. Object deletion is not mandatory as the scripting engine will [[Garbage collection (computer science)|garbage collect]] any variables that are no longer being referenced.