Can you tell me which approach is considered the best practice?
Is it better to use the "this" statement in the following way:
var obj = {
x: 20,
y: 10,
width: this.x,
height: this.y,
render: function () { // renders object on canvas
ctx.fillRect(this.x, this.y, this.width, this.height);
}
};
Or should I refer to the object by its name like this:
var obj = {
x: 20,
y: 10,
width: obj.x,
height: obj.y,
render: function () { // renders object on canvas
ctx.fillRect(obj.x, obj.y, obj.width, obj.height);
}
};
Thanks a lot for your help!