Last active
August 29, 2015 14:27
-
-
Save kulakowka/3ede7ab6e35e45152a1c to your computer and use it in GitHub Desktop.
static methods and params for class
This file contains 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 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