2 ms·
Trying some simple this-based class/instance-construction in the constructor leads to the whole thing failing: var Person = function (name) { console
by josteink 11y ago
Trying some simple this-based class/instance-construction in the constructor leads to the whole thing failing:
var Person = function (name) {
console.log('This is the constructor.');
var _name = name;
this.getName = function() {
return _name;
};
};
Since this is 1 of the 2 patterns for creating classes, and the only one which supports encapsulation, it seems like a strange omission.
Especially so if the goal is to migrate "old" javascript to get it "modern". Migrating bleeding edge JS to even more bleeding edge JS hardly seems like a very worthwhile endeavour.