Skip to content

Instantly share code, notes, and snippets.

@amjedomar
Last active August 12, 2022 11:13
Show Gist options
  • Select an option

  • Save amjedomar/ad6b8230edfaf38badf7000dffc58cfa to your computer and use it in GitHub Desktop.

Select an option

Save amjedomar/ad6b8230edfaf38badf7000dffc58cfa to your computer and use it in GitHub Desktop.
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