Skip to content

Commit

Permalink
Editorial: Remove PNG for the prototype graph (#3239)
Browse files Browse the repository at this point in the history
  • Loading branch information
arai-a authored and ljharb committed Jan 10, 2024
1 parent 5be7f2c commit a231519
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 1 deletion.
Binary file removed img/figure-1.png
Binary file not shown.
2 changes: 1 addition & 1 deletion spec.html
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ <h1>Objects</h1>
<p>Even though ECMAScript includes syntax for class definitions, ECMAScript objects are not fundamentally class-based such as those in C++, Smalltalk, or Java. Instead objects may be created in various ways including via a literal notation or via <em>constructors</em> which create objects and then execute code that initializes all or part of them by assigning initial values to their properties. Each constructor is a function that has a property named *"prototype"* that is used to implement <em>prototype-based inheritance</em> and <em>shared properties</em>. Objects are created by using constructors in <b>new</b> expressions; for example, `new Date(2009, 11)` creates a new Date object. Invoking a constructor without using <b>new</b> has consequences that depend on the constructor. For example, `Date()` produces a string representation of the current date and time rather than an object.</p>
<p>Every object created by a constructor has an implicit reference (called the object's <em>prototype</em>) to the value of its constructor's *"prototype"* property. Furthermore, a prototype may have a non-*null* implicit reference to its prototype, and so on; this is called the <em>prototype chain</em>. When a reference is made to a property in an object, that reference is to the property of that name in the first object in the prototype chain that contains a property of that name. In other words, first the object mentioned directly is examined for such a property; if that object contains the named property, that is the property to which the reference refers; if that object does not contain the named property, the prototype for that object is examined next; and so on.</p>
<emu-figure id="figure-1" caption="Object/Prototype Relationships">
<object data="img/figure-1.svg" height="354" type="image/svg+xml" width="719"><img alt="An image of lots of boxes and arrows." height="354" src="img/figure-1.png" width="719"></object>
<img alt="An image of lots of boxes and arrows." height="354" src="img/figure-1.svg" width="719">
</emu-figure>
<p>In a class-based object-oriented language, in general, state is carried by instances, methods are carried by classes, and inheritance is only of structure and behaviour. In ECMAScript, the state and methods are carried by objects, while structure, behaviour, and state are all inherited.</p>
<p>All objects that do not directly contain a particular property that their prototype contains share that property and its value. Figure 1 illustrates this:</p>
Expand Down

0 comments on commit a231519

Please sign in to comment.