Sunday, March 8, 2015

JavaScript Object.observe()

Object.observe() is a part of  ECMA7Script7 ,is now landed in chrome36+. This is a method for asynchronously observing changes to javaScript objects.
Let's look at an example,


In the above code , the changes to the object "example" is observed , and it outputs the change type, change name , old value etc. The code is pretty much simple and self  explanatory.Just go through and you will understand it.
With this feature, two way data binding can be implemented without any MVC framework like Angular.
Sources:
http://www.html5rocks.com/en/tutorials/es7/observe/
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/observe

No comments:

Post a Comment