Because of the scoping rules, you cannot actually examine the value of the variable that has changed since the event handler is running in a completely different scope chain.
<HTML>
<HEAD></HEAD>
<BODY>
<SCRIPT>
function watchFunct()
{
alert("Variable changed");
}
watch("myVariable", watchFunct)
myVariable = 100;
myVariable = 200;
unwatch("myVariable")
myVariable = 300;
</SCRIPT>
</BODY>
</HTML>| See also: | Object.assign(), Object.watch() |
| Prev | Home | Next |
| Object.toString() | Up | Object.valueOf() |
JavaScript Programmer's Reference, Cliff Wootton Wrox Press (www.wrox.com) Join the Wrox JavaScript forum at p2p.wrox.com Please report problems to support@wrox.com © 2001 Wrox Press. All Rights Reserved. Terms and conditions. | ||