Skip to main content

isEventTarget

Detect whether an object is EventTarget.

API

function isEventTarget(target: any): target is EventTarget;

Example

import { isEventTarget } from "@lilib/utils";

if (isEventTarget(element)) {
element.addEventListener("click", () => {
// Do something.
});
}