Proxy is a structural design pattern that lets you provide a substitute or placeholder for another object. A proxy controls access to the original object, allowing you to perform something either before or after the request gets through to the original object.
Letโs create a person object, that represents John Doe.
Now lets analyze an interview question :
๐๐ผ๐ ๐ฐ๐ฎ๐ป ๐ถ ๐๐๐ผ๐ฝ ๐๐ผ๐บ๐ฒ๐ผ๐ป๐ฒ ๐๐ผ ๐ฐ๐ต๐ฎ๐ป๐ด๐ฒ ๐๐ต๐ฒ ๐ถ๐ฑ ๐ถ๐ป ๐๐ต๐ฒ ๐๐๐ฒ๐ฟ ๐ผ๐ฏ๐ท๐ฒ๐ฐ๐ ?
To freeze the id property in a JavaScript object using a Proxy, you can define a Proxy handler that prevents the id property from being modified. Here's how you can do it :
Keep Exploring JS โค
Top comments (0)