Object.watch() : Object « Object Oriented « JavaScript Tutorial






Syntax

object.watch(prop, function)

The watch() method watches for the event in which a property gets assigned a value.

When the assignment is made, a user defined function is executed.

The method itself takes the property to watch, prop, and the function to call, func, when the event occurs.

<html>
    <body>
    <title>Example of the watch method</title>
    <script language="JavaScript">
    <!--
    function inform(){
         document.write("Tmp variable changed from 1 to 3");
    }
    var tmp = 1;

    watch("tmp",inform);

    tmp=3;
    -->
    </script>
    </body>
    </html>








25.2.Object
25.2.1.The Object Class
25.2.2.Object()
25.2.3.Object.constructor
25.2.4.Object.eval()
25.2.5.Object.prototype
25.2.6.Object.toSource()
25.2.7.Object.toString()
25.2.8.Object.unwatch()
25.2.9.Object.valueOf()
25.2.10.Object.watch()
25.2.11.Add method to Object class