Logo

dev-resources.site

for different kinds of informations.

What are Proxies in JavaScript, and how are they used?

Published at
1/13/2025
Categories
Author
Anjali Gurjar
Categories
1 categories in total
open
What are Proxies in JavaScript, and how are they used?

A Proxy in JavaScript is an object that wraps another object (called the target) and intercepts operations performed on the target, such as property access, assignment, function invocation, and more. Proxies allow you to define custom behavior for fundamental operations on objects.

What are WeakMaps and WeakSets in JavaScript?
Answer:

WeakMap: A collection of key-value pairs where the keys must be objects and the values can be arbitrary values. The keys in WeakMap are held weakly, meaning they do not prevent garbage collection.
WeakSet: A collection of objects, held weakly. Objects in a WeakSet can be garbage-collected if there are no other references to them.

Featured ones: