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>