JSFiddle - React, Tailwind, and code Playground
by alexflav23
JavaScript
var vector = function( x, y ) {
this.x = x || 0;
this.y = y || 0;
}
var obj = function() {
this.position = new vector( 0, 0, 0 );
}
obj.prototype = {};
Object.defineProperty(obj.prototype, 'x', {
get: function () {
return this.position.x;
},
set: function (val) {
this.position.x = val;
}
});
var cube = new obj();
cube.x; //0
cube.x = 10;
cube.position.x; //10