I want to have a static property in an ES6 class. This property value is initially an empty array.
class Game{
constructor(){
// this.cards = [];
}
static cards = [];
}
Game.cards.push(1);
console.log(Game.cards);
How can I do it?
class Game{
constructor(){}
}
Game.cards = [];
Game.cards.push(1);
console.log(Game.cards);
You can define a static variable like that.