---
title: "getEventListeners | JavaScript maps SDK"
description: "Documentation for MapTiler SDK"
---

> For AI agents: a documentation index is available at [/llms.txt](https://docs.maptiler.com/llms.txt). Markdown versions of all pages are available by appending .md to any URL.

# Function getEventListeners

-   getEventListeners(  
        emitter: [EventEmitter](https://docs.maptiler.com/sdk-js/api-reference/classes/Externals.EventEmitter/),  
        name: string | symbol,  
    ): ((...args: any\[\]) \=> void)\[\][](#geteventlisteners)
    
    Returns a copy of the array of listeners for the event named `eventName`.
    
    For `EventEmitter`s this behaves exactly the same as calling `.listeners` on the emitter.
    
    For `EventTarget`s this is the only way to get the event listeners for the event target. This is useful for debugging and diagnostic purposes.
    
    ```typescript
    import { getEventListeners, EventEmitter } from 'node:events';
    
    {
      const ee = new EventEmitter();
      const listener = () => console.log('Events are fun');
      ee.on('foo', listener);
      console.log(getEventListeners(ee, 'foo')); // [ [Function: listener] ]
    }
    {
      const et = new EventTarget();
      const listener = () => console.log('Events are fun');
      et.addEventListener('foo', listener);
      console.log(getEventListeners(et, 'foo')); // [ [Function: listener] ]
    }
    ```
    
    #### Parameters
    
    -   emitter: [EventEmitter](https://docs.maptiler.com/sdk-js/api-reference/classes/Externals.EventEmitter/)
    -   name: string | symbol
    
    #### Returns ((...args: any\[\]) \=> void)\[\]
    
    #### Since[](#since)
    
    v15.2.0, v14.17.0
    
-   getEventListeners(  
        emitter: EventTarget,  
        name: string,  
    ): ((...args: any\[\]) \=> void)\[\][](#geteventlisteners-1)
    
    Returns a copy of the array of listeners for the event named `eventName`.
    
    For `EventEmitter`s this behaves exactly the same as calling `.listeners` on the emitter.
    
    For `EventTarget`s this is the only way to get the event listeners for the event target. This is useful for debugging and diagnostic purposes.
    
    ```typescript
    import { getEventListeners, EventEmitter } from 'node:events';
    
    {
      const ee = new EventEmitter();
      const listener = () => console.log('Events are fun');
      ee.on('foo', listener);
      console.log(getEventListeners(ee, 'foo')); // [ [Function: listener] ]
    }
    {
      const et = new EventTarget();
      const listener = () => console.log('Events are fun');
      et.addEventListener('foo', listener);
      console.log(getEventListeners(et, 'foo')); // [ [Function: listener] ]
    }
    ```
    
    #### Parameters
    
    -   emitter: EventTarget
    -   name: string
    
    #### Returns ((...args: any\[\]) \=> void)\[\]
    
    #### Since[](#since-1)
    
    v15.2.0, v14.17.0
