Question

I recently came to know this function Object.observe() and tried implementing in my app.

var cs = {
    name : "java",
    version : "1.0"
}

cs.name = "javascript";
function doThis(){
    console.log(cs.name);
}
Object.observe(cs, doThis);

But I see the above mentioned error.

TypeError: Object function Object() { [native code] } has no method 'observe'

Can some one throw some light on what am I missing here.

Was it helpful?

Solution

If I'm not mistaken it only exists in google canary at the moment, it is an extremely new JS prototype.

You are getting this error because the browser you are using does not have it implemented.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top