Czytasz angielską wersję tego artykułu, ponieważ nie ma jeszcze tłumaczenia dla tego języka. Pomóż nam przetłumaczyć ten artykuł!

This feature is obsolete. Although it may still work in some browsers, its use is discouraged since it could be removed at any time. Try to avoid using it.

The handler.enumerate() method used to be a trap for for...in statements, but has been removed from the ECMAScript standard in ES2016 and is deprecated in browsers.


var p = new Proxy(target, {
  enumerate(target) {


The following parameter is passed to the enumerate method. this is bound to the handler.

The target object.

Return value

An iterator object.


The handler.enumerate method is a trap for for...in statements.


This trap can intercept these operations:


If the following invariants are violated, the proxy will throw a TypeError:

  • The enumerate method must return an object.


The following code traps for...in statements.

var p = new Proxy({}, {
  enumerate(target) {
    return ['a', 'b', 'c'][Symbol.iterator]();

for (var x in p) { // "called"
  console.log(x);  // "a"
}                  // "b"
                   // "c"

The following code violates the invariant.

var p = new Proxy({}, {
  enumerate(target) {
    return 1;

for (var x in p) {} // TypeError is thrown

Note: Both examples make use of the shorthand syntax for method definitions.


Specification Status Comment
ECMAScript 2015 (6th Edition, ECMA-262)
The definition of '[[Enumerate]]' in that specification.
Standard Initial definition. Removed in ECMAScript 2016.

Browser compatibility

Update compatibility data on GitHub
ChromeEdgeFirefoxInternet ExplorerOperaSafariAndroid webviewChrome for AndroidFirefox for AndroidOpera for AndroidSafari on iOSSamsung InternetNode.js
Chrome No support NoEdge No support NoFirefox No support 37 — 47IE No support NoOpera No support NoSafari No support NoWebView Android No support NoChrome Android No support NoFirefox Android No support 37 — 47Opera Android No support NoSafari iOS No support NoSamsung Internet Android No support Nonodejs No support No


No support  
No support
Non-standard. Expect poor cross-browser support.
Non-standard. Expect poor cross-browser support.
Deprecated. Not for use in new websites.
Deprecated. Not for use in new websites.

See also