| defineProperty | var obj = function() {};
Object.defineProperty(obj.prototype, 'width', {
get: function() {
return this.width_;
},
set: function(w) {
this.width_ = Number(w);
}
});
Object.defineProperty(obj.prototype, 'height', {
get: function() {
return this.height_;
},
set: function(h) {
this.height_ = Number(h);
}
});
var o1 = new obj();
o1.width = 1;
o1.height = 1;
o1.width;
o1.height;
| ready |
| defineProperties | var obj = function() {};
Object.defineProperties(obj.prototype, {
width: {
get: function() {
return this.width_;
},
set: function(w) {
this.width_ = Number(w);
}
},
height: {
get: function() {
return this.height_;
},
set: function(h) {
this.height_ = Number(h);
}
}
});
var o1 = new obj();
o1.width = 1;
o1.height = 1;
o1.width;
o1.height;
| ready |
| getter | var obj = function() {};
obj.prototype = {
get width() {
return this.width_;
},
set width(w) {
this.width_ = Number(w);
},
get height() {
return this.height_;
},
set height(h) {
this.height_ = Number(h);
}
};
var o1 = new obj();
o1.width = 1;
o1.height = 1;
o1.width;
o1.height;
| ready |
| Object.create | var obj = function() {};
obj.prototype = Object.create(Object.prototype, {
width: {
get: function() {
return this.width_;
},
set: function(w) {
this.width_ = Number(w);
}
},
height: {
get: function() {
return this.height_;
},
set: function(h) {
this.height_ = Number(h);
}
}
});
var o1 = new obj();
o1.width = 1;
o1.height = 1;
o1.width;
o1.height;
| ready |