var div = document.querySelector("div");
Object.defineProperties(div,{
_width:{
writable:true,
value:0,
},
_height:{
writable:true,
value:0,
},
_bgColor:{
writable:true,
value:0,
},
width:{
enumerable:true,
set:function(_value){
this.style.width = _value.toString().indexOf("px")>-1 ? _value : _value + "px";
this._width = _value;
},
get:function(){
return this._width;
},
},
height:{
enumerable:true,
set:function(_value){
this.style.height = _value.toString().indexOf("px")>-1 ? _value : _value+"px";
this._height = _value;
},
get:function(){
return this._height;
},
},
bgColor:{
enumerable:true,
set:function(_value){
this.style.backgroundColor = typeof _value === "String" ? _value :"#"+_value.toString(16).padStart(6,"0");
this._bgColor = _value;
},
get:function(){
return this._bgColor;
},
},
});
setInterval(function(){
div.width++;
div.height++;
div.bgColor++;
},100)