Last active
August 12, 2022 11:13
-
-
Save amjedomar/ad6b8230edfaf38badf7000dffc58cfa 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 Cat { | |
| static count = 0; | |
| constructor(public name: string) { | |
| Cat.count++; | |
| } | |
| getName() { | |
| return this.name; | |
| } | |
| static getCount() { | |
| return this.count; | |
| } | |
| } | |
| // access instance properties and methods | |
| const milo = new Cat('Milo'); | |
| console.log(milo.name); | |
| console.log(milo.getName()); | |
| // access static properties and methods | |
| console.log(Cat.count); | |
| console.log(Cat.getCount()); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment