You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
<p>As soon as JavaScript executes this statement, the <code>mark</code> object also has the <code>specialty</code> property with the value of <code>"none"</code>. The following figure shows the effect of adding this property to the <code>Employee</code> prototype and then overriding it for the <code>Engineer</code> prototype.</p>
<p>The constructor functions shown so far do not let you specify property values when you create an instance. As with Java, you can provide arguments to constructors to initialize property values for instances. The following figure shows one way to do this.</p>
317
314
318
-
<figure>
319
-
<imgalt="" class="internal" src="figure8.5.png">
320
-
<figcaption>Specifying properties in a constructor, take 1</figcaption>
321
-
</figure>
315
+
<imgalt="Specifying properties in a constructor, take 1" src="figure8.5.png">
322
316
323
317
<p>The following pairs of examples show the Java and JavaScript definitions for these objects.</p>
<p>So far, the constructor function has created a generic object and then specified local properties and values for the new object. You can have the constructor add more properties by directly calling the constructor function for an object higher in the prototype chain. The following figure shows these new definitions.</p>
412
406
413
-
<figure>
414
-
<imgalt="" class="internal" src="figure8.6.png">
415
-
<figcaption>Specifying properties in a constructor, take 2</figcaption>
416
-
</figure>
407
+
<imgalt="Specifying properties in a constructor, take 2" src="figure8.6.png">
417
408
418
409
<p>Let's look at one of these definitions in detail. Here's the new definition for the <code>Engineer</code> constructor:</p>
0 commit comments