大网数据广告活动
Web 标准与前端开发

EventCounts

· 52CE 我爱测

The **`EventCounts`** interface of the Performance API provides the number of events that have been dispatched for each event type.

Performance API

The EventCounts interface of the Performance API provides the number of events that have been dispatched for each event type.

An EventCounts instance is a read-only Map-like object, in which each key is the name string for an event type, and the corresponding value is an integer indicating the number of events that have been dispatched for that event type.

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 (const [type, count] of performance.eventCounts.entries()) {
  console.log(type, count);
}

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

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

Specifications

Browser compatibility

See also

  • performance.eventCounts
  • PerformanceEventTiming
  • Map

来源:MDN Web Docs / Mozilla 贡献者 · 作者与贡献记录 · CC BY-SA 2.5。离线整理了版式、链接和媒体显示。

资料来源与适用范围

资料来源
MDN Web Docs / Mozilla 贡献者
适用范围
请按文中版本与环境说明核对
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 2.5

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。