mozilla

Revision 493929 of Object.prototype.unwatch()

  • Revision slug: Web/JavaScript/Reference/Global_Objects/Object/unwatch
  • Revision title: Object.prototype.unwatch()
  • Revision id: 493929
  • Created:
  • Creator: fscholz
  • Is current revision? No
  • Comment cleanup

Revision Content

{{JSRef("Global_Objects", "Object")}}
Warning: Generally you should avoid using unwatch() and {{jsxref("Object.watch", "watch()")}} when possible. These two methods are implemented only in Gecko, and they're intended primarily for debugging use. In addition, using watchpoints has a serious negative impact on performance, which is especially true when used on global objects, such as window. You can usually use setters and getters or proxies instead. See {{ anch("Browser compatibility") }} for details.

Summary

The unwatch() method removes a watchpoint set with the {{jsxref("Object.watch", "watch()")}} method.

Syntax

obj.unwatch(prop)

Parameters

prop
The name of a property of the object to stop watching.

Description

The JavaScript debugger has functionality similar to that provided by this method, as well as other debugging options. For information on the debugger, see Venkman.

By default, this method is inherited by every object descended from Object.

Note: The reason for unwatch() to take the property name prop as its only parameter is due to the "single handler allowing" behavior of the {{jsxref("Object.watch", "watch()")}} method.

Examples

See {{jsxref("Object.watch", "watch()")}}.

Specifications

Not part of any specifications. Implemented in JavaScript 1.2.

Browser compatibility

{{ CompatibilityTable() }}

Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari
Basic support {{ CompatNo() }} {{ CompatVersionUnknown() }} {{ CompatNo() }} {{ CompatNo() }} {{ CompatNo() }}
Feature Android Chrome for Android Firefox Mobile (Gecko) IE Mobile Opera Mobile Safari Mobile
Basic support {{ CompatNo() }} {{ CompatNo() }} {{ CompatVersionUnknown() }} {{ CompatNo() }} {{ CompatNo() }} {{ CompatNo() }}
Note: Calling unwatch() on the {{ domxref("Document") }} object throws a {{jsxref("Global_Objects/TypeError", "TypeError")}} since Firefox 23 ({{ bug(903332) }}). This regression has been fixed with Firefox 27.

See also

  • {{jsxref("Object.watch()")}}

Revision Source

<div>
 {{JSRef("Global_Objects", "Object")}}</div>
<div class="warning">
 <strong>Warning:</strong> Generally you should avoid using <code>unwatch()</code> and {{jsxref("Object.watch", "watch()")}} when possible. These two methods are implemented only in Gecko, and they're intended primarily for debugging use. In addition, using watchpoints has a serious negative impact on performance, which is especially true when used on global objects, such as window. You can usually use <a href="/en-US/docs/Web/JavaScript/Guide/Working_with_Objects#Defining_getters_and_setters">setters and getters</a> or proxies instead. See {{ anch("Browser compatibility") }} for details.</div>
<h2 id="Summary" name="Summary">Summary</h2>
<p>The <code><strong>unwatch()</strong></code> method removes a watchpoint set with the {{jsxref("Object.watch", "watch()")}} method.</p>
<h2 id="Syntax" name="Syntax">Syntax</h2>
<pre class="syntaxbox">
<code><var>obj</var>.unwatch(<em>prop</em>)</code></pre>
<h3 id="Parameters" name="Parameters">Parameters</h3>
<dl>
 <dt>
  <code>prop</code></dt>
 <dd>
  The name of a property of the object to stop watching.</dd>
</dl>
<h2 id="Description" name="Description">Description</h2>
<p>The JavaScript debugger has functionality similar to that provided by this method, as well as other debugging options. For information on the debugger, see <a href="/en-US/docs/Venkman" title="Venkman">Venkman</a>.</p>
<p>By default, this method is inherited by every object descended from <code>Object</code>.</p>
<div class="note">
 <strong>Note:</strong> The reason for <code>unwatch()</code> to take the property name <em>prop</em> as its only parameter is due to the "single handler allowing" behavior of the {{jsxref("Object.watch", "watch()")}}<code> </code>method.</div>
<h2 id="Examples" name="Examples">Examples</h2>
<p>See {{jsxref("Object.watch", "watch()")}}.</p>
<h2 id="See_also" name="See_also">Specifications</h2>
<p>Not part of any specifications. Implemented in JavaScript 1.2.</p>
<h2 id="Browser_compatibility">Browser compatibility</h2>
<p>{{ CompatibilityTable() }}</p>
<div id="compat-desktop">
 <table class="compat-table">
  <tbody>
   <tr>
    <th>Feature</th>
    <th>Chrome</th>
    <th>Firefox (Gecko)</th>
    <th>Internet Explorer</th>
    <th>Opera</th>
    <th>Safari</th>
   </tr>
   <tr>
    <td>Basic support</td>
    <td>{{ CompatNo() }}</td>
    <td>{{ CompatVersionUnknown() }}</td>
    <td>{{ CompatNo() }}</td>
    <td>{{ CompatNo() }}</td>
    <td>{{ CompatNo() }}</td>
   </tr>
  </tbody>
 </table>
</div>
<div id="compat-mobile">
 <table class="compat-table">
  <tbody>
   <tr>
    <th>Feature</th>
    <th>Android</th>
    <th>Chrome for Android</th>
    <th>Firefox Mobile (Gecko)</th>
    <th>IE Mobile</th>
    <th>Opera Mobile</th>
    <th>Safari Mobile</th>
   </tr>
   <tr>
    <td>Basic support</td>
    <td>{{ CompatNo() }}</td>
    <td>{{ CompatNo() }}</td>
    <td>{{ CompatVersionUnknown() }}</td>
    <td>{{ CompatNo() }}</td>
    <td>{{ CompatNo() }}</td>
    <td>{{ CompatNo() }}</td>
   </tr>
  </tbody>
 </table>
</div>
<div class="note">
 <strong>Note:</strong> Calling <code>unwatch()</code> on the {{ domxref("Document") }} object throws a {{jsxref("Global_Objects/TypeError", "TypeError")}} since Firefox&nbsp;23 ({{ bug(903332) }}). This regression has been fixed with Firefox&nbsp;27.</div>
<h2 id="See_also" name="See_also">See also</h2>
<ul>
 <li>{{jsxref("Object.watch()")}}</li>
</ul>
Revert to this revision