How can I utilize the setter method to update existing values of an object and perform mathematical operations?
var obj = {
set model(object) {
//method's logic
}
};
obj = {x:10, y: 20, p: 15};
obj = {
x:10,
y: 20,
p: 15
set model(object){
//method logic
}
};
obj.model = { x: { value: 33, operation: '*' },
z: { value: 75, operation: '+' },
p: { value: 4, operation: '%' } };
console.log(obj); // -> {x:330, y: 20, z: 75, p: 3}