1

I understand that Angular uses dirty checking and Ember attach some watcher to the objects to detect changes. My question is how Object.observe() detect the change? How does it know when to trigger? Doesn't it also have some watcher like thing in prototype?

Bergi
  • 513,640
  • 108
  • 821
  • 1,164
  • Its implemented by the browser internally. So different browser might have different implementations. As it is native it will be fast compared to other implementations. – Shaik Mahaboob Basha Sep 17 '14 at 06:51
  • Yaa it will be faster no doubt. I just want to know what approach it uses to detect the changes – Prasenjit Paul Sep 17 '14 at 07:04
  • 2
    @PrasenjitPaul: Obviously the javascript interpreter will know when a variable gets a new value no? Otherwise how does javascript ever assign any value to any variable? – slebetman Sep 17 '14 at 07:40
  • 2
    @PrasenjitPaul: The main change is that variables in the interpreter are now themselves event emitters. It's not all that much different from older versions of javascript where some special objects such as document and img emit onchange events. – slebetman Sep 17 '14 at 07:42
  • @slebetman Thanks man! Your answer helped! :) – Prasenjit Paul Sep 17 '14 at 08:20

0 Answers0