Watchpoint handler (Interface)

The handler that is connected to a watch point has a special pre-defined API specification.

JavaScript syntax:-function anId(aProp, oldVal, newVal) { someCode; return actualVal}
Argument list:actualValThe value that will be placed into the property
anIdA name for your handler function
aPropA formal parameter to pass the property name in
newValA format parameter to pass the new value in
oldValA formal parameter to pass the old value in

Your handler function is passed to the watch() method belonging to the object whose property you want to monitor.

When that property changes, your handler will be called.

You will be passed the following:

Whatever you return from this handler will be stored in the property and will become its new value. This means you can return the old value, forcing the property to be read-only. You might change the new value to something else. Perhaps you would force the value to be all uppercase regardless of how it had been specified. You may even want to display an alert to warn the operator that the property is being changed.

See also:watch()