11 lines
656 B
Text
11 lines
656 B
Text
<span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">Car</span> <span class="hljs-keyword">extends</span> <span class="hljs-title">Vehicle</span> </span>{
|
|
<span class="hljs-keyword">constructor</span>(speed, cost) {
|
|
<span class="hljs-keyword">super</span>(speed);
|
|
|
|
<span class="hljs-keyword">var</span> c = <span class="hljs-built_in">Symbol</span>(<span class="hljs-string">'cost'</span>);
|
|
<span class="hljs-keyword">this</span>[c] = cost;
|
|
|
|
<span class="hljs-keyword">this</span>.intro = <span class="hljs-string">`This is a car runs at
|
|
<span class="hljs-subst">${speed}</span>.`</span>;
|
|
}
|
|
}
|