1

Is there any way to trigger a function when setting the property of an object?

function Vector(x,y,z){
this.x= Quaternion(x);
this.y=y;
this.z=z;
}

function Quaternion(x,y,z,w){
this.x=x;
this.y=y;
this.z=z;
this.w=w;
}
techdog
  • 1,451
  • 3
  • 19
  • 38
  • What language is used in this post? If using a specific language, make sure to add the tag. – 0xCursor Aug 23 '18 at 03:53
  • 1
    Yes, you could do that using a Proxy object - https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Proxy – dysfunc Aug 23 '18 at 04:26
  • Possible duplicate of [Listener for property value changes in a Javascript object](https://stackoverflow.com/questions/1063813/listener-for-property-value-changes-in-a-javascript-object) – showdev Jul 05 '19 at 07:23

0 Answers0