EventCounts

The EventCounts interface is a read-only map where the keys are event types and the values are the number of events that have been dispatched for that event type.

As a read-only map, EventCounts is similar to a Map, however, it doesn't implement the clear(), delete(), and set() methods.

Constructor

This interface has no constructor. You typically get an instance of this object using the performance.eventCounts property.

Instance properties

size

See Map.prototype.size for details.

Instance methods

entries()

See Map.prototype.entries() for details.

forEach()

See Map.prototype.forEach() for details.

get()

See Map.prototype.get() for details.

has()

See Map.prototype.has() for details.

keys()

See Map.prototype.keys() for details.

values()

See Map.prototype.values() for details.

Examples

Working with EventCount maps

Below are a few examples to get information from an EventCounts map. Note that the map is read-only and the clear(), delete(), and set() methods aren't available.

for (entry of performance.eventCounts.entries()) {
  const type = entry[0];
  const count = entry[1];
}

const clickCount = performance.eventCounts.get("click");

const isExposed = performance.eventCounts.has("mousemove");
const exposedEventsCount = performance.eventCounts.size;
const exposedEventsList = [...performance.eventCounts.keys()];

Specifications

Specification
Event Timing API
# sec-event-counts

Browser compatibility

BCD tables only load in the browser

See also