mirror of
https://github.com/cupcakearmy/typescript-talk.git
synced 2024-12-22 08:06:31 +00:00
shorten constructor
This commit is contained in:
parent
e3e331ddf8
commit
d277b69614
18
index.html
18
index.html
@ -466,24 +466,6 @@
|
||||
}
|
||||
</code></pre>
|
||||
</section>
|
||||
<section>
|
||||
<h3>Advanced Stuff</h3>
|
||||
<pre><code data-trim class="hljs">
|
||||
class Auto {
|
||||
wheels?: number
|
||||
doors?: number
|
||||
// ...
|
||||
|
||||
constructor(init: Partial<Auto>) {
|
||||
Object.assign(this, init)
|
||||
}
|
||||
}
|
||||
|
||||
const a = new Auto({
|
||||
doors: 5,
|
||||
})
|
||||
</code></pre>
|
||||
</section>
|
||||
<section>
|
||||
<h3>Advanced Stuff</h3>
|
||||
<pre><code data-trim class="hljs">
|
||||
|
Loading…
Reference in New Issue
Block a user