Skip to content

Instantly share code, notes, and snippets.

@kulakowka
Last active August 29, 2015 14:27
Show Gist options
  • Save kulakowka/3ede7ab6e35e45152a1c to your computer and use it in GitHub Desktop.
Save kulakowka/3ede7ab6e35e45152a1c to your computer and use it in GitHub Desktop.
static methods and params for class
class Item {
constructor() {
this.id = Item.count++;
}
}
Item.count = 0;
Item.getCount = function() {
return this.count;
};
class Model extends Item {
constructor(name) {
super();
this.name = name;
}
}
console.log(new Model('nissan'));
console.log(new Model('mazda'));
console.log(Item.getCount());
/*
{ id: 0, name: 'nissan' }
{ id: 1, name: 'mazda' }
2
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment