I'm checking new ES6 cool things
, and now I am learning new classes definitions.
All is clear, class
, extends
, constructor
, etc.
Example:
class AnimalES6 {
constructor(name) {
this._name = name;
}
get name() {
return this._name;
}
}
var animal = new AnimalES6('Tiger');
console.log(animal.name); // Tiger
But what about destruct
?
Can I call some function, when object dies, like in PHP/JAVA?
animal = null; // "Now" (but not in this moment =) ) destruct() method must be called