Когда вы используете «строгий», вы не можете использовать необъявленную переменную. После "this.name = name;" поставить "вар температура";
'use strict';
class DataClass{
constructor(name){
this.name = name;
var temperature; // <- private variable, completely different from the public one.
Object.defineProperties(this, {
_archives :{
value : []
},
temperature : { // <- public variable Object.temperature, internally this.temperature
enumerable : true,
set : function(value){
// error message : InternalError: too much recursion
//this.temperature = value; <-- Call the set again, that's why the loop.
//error message in case of 'use strict' : ReferenceError: assignment to undeclared variable temperature
temperature = value;
this._archives.push(value);
},
get : function(){
return ' yyy ';
}
},
});
}
}
var dataClass1 = new DataClass('giovanni');
dataClass1.temperature = 45;
console.log(dataClass1.temperature);