What is the alternative of Object.observe as it is already been deprecated

9.2k Views Asked by At

As O.o is already been deprecated what are the other options we have to observe the properties of a Javascript Object.

2

There are 2 best solutions below

1
Magus On

As stated in the mdn documentation : https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/observe

The Object.observe() method was used for asynchronously observing the changes to an object. It provided a stream of changes in the order in which they occur. However, this API has been deprecated and removed from browsers. You can use the more general Proxy object instead.

2
sujeet kumar srivastava On

you can achieve this with getters and setters and alternatively, in a browser with support for Proxies, you can write a more generic solution. Check here