Created
November 26, 2018 13:00
-
-
Save ragmha/1b551700e697ece98996710091b01403 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class Sizes { | |
| constructor(public sizes: string[]) {} | |
| set availableSizes(sizes: string[]) { | |
| this.sizes = sizes; | |
| } | |
| get availableSizes() { | |
| return this.sizes; | |
| } | |
| } | |
| const sizes = new Sizes(["small", "medium"]); | |
| console.log(`Sizes available => ${sizes.sizes}`); | |
| sizes.availableSizes = ["large", "extra-large"]; | |
| console.log(`New Sizes available => ${sizes.sizes}`); | |
| class Pizza { | |
| public toppings: string[] = []; | |
| constructor(readonly name: string) {} | |
| public addToping(topping: string): void { | |
| this.toppings.push(topping); | |
| } | |
| get orderName() { | |
| return this.name; | |
| } | |
| } | |
| const pizza = new Pizza("Papa John islands"); | |
| pizza.addToping("Super"); | |
| const { orderName } = pizza; | |
| console.log(`Pizza order => ${orderName}`); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment