vanillajs-browser-helpers
Version:
Collection of convenience code snippets (helpers) that aims to make it a little easier to work with vanilla JS in the browser
11 lines (10 loc) • 366 B
JavaScript
/**
* Is the given object a viable event target (implements the addEventListener function)
*
* @param obj - The object to check
* @return Is it an Event Target or not
*/
export default (obj) => !!obj
&& typeof obj.addEventListener === 'function'
&& typeof obj.removeEventListener === 'function'
&& typeof obj.dispatchEvent === 'function';