Back to Content

ErrorEvent: filename property

files/en-us/web/api/errorevent/filename/index.md

latest438 B
Original Source

{{APIRef("HTML DOM")}}{{AvailableInWorkers}}

The filename read-only property of the {{domxref("ErrorEvent")}} interface returns a string containing the name of the script file in which the error occurred.

Value

A string.

Examples

js
window.addEventListener("error", (ev) => {
  console.log(`The error occur in file: ${ev.filename}`);
});

Specifications

{{Specifications}}

Browser compatibility

{{Compat}}