Hey guys i have seen some code from mdn about Object.defineProperty().
The code is
function Archiver() {
var temperature = null;
var archive = [];
Object.defineProperty(this, 'temperature', {
get: function() {
console.log('get!');
return temperature;
},
set: function(value) {
temperature = value;
archive.push({
val: temperature
});
}
});
this.getArchive = function() {
return archive;
};
}
I know inside the object of defineProperty() this refers to the function Archiver().
But i dont know what this points to inside the obj section Object.defineProperty(this, 'temperature', {
Does this also points to the function Archiver() ??
Any help would be appreciated..
Aucun commentaire:
Enregistrer un commentaire