Q:

Passing additional arguments to an event callback function

I need to pass additional arguments to a function on an event.
I tried bind but it only passes the e and not the result data:
locationSearch.on("result", dropMarker.bind(this, e) );

I could do:
locationSearch.on("result", function(data) {
    dropMarker({ 
        e: e,
        data: data
    });
};

... but then I can't disable the listener locationSearch.off(...) since it is an anonymous function. 

A:

Just wrap the function call in another function that will become the callback
locationSearch.on("result", wrapper);

function wrapper(e) { dropMarker(e, data); }

Here's an example:

$("button").on("click", wrapper);

let data = "some data";

function wrapper(e){
  // The wrapper just calls the actual handler
  handler(e, data);
}

function handler(e, data){
  // Because the wrapper was named, it can be disconnected
  $(e.target).off("click", wrapper);
  
  // And you can do whatever you need to
  console.log(e.type, data);
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<button>Click Me</button>

