DEV Community

loading...

Discussion on: Automate your getters and setters with Proxies

Collapse
aminnairi profile image
Amin Author • Edited

Hi Stephen and thanks for your question which is interesting!

The set trap will be triggered when you set a property for the object that is being proxied.

motorcycle.brand = "Triumph";

But when using the setter method motorcycle.setBrand("Triumph"); you are really just triggering the get trap, whether it is a property or in this case a method. Using a set trap wouldn't have helped us much.

Hope this answers your question.

Forem Open with the Forem app