You would need to store the function in a variable so that you can reference it when removing it.
var handler;
handler = function () {
/* ... */
removeEventListener("theEvent", handler);
};
addEventListener("theEvent", handler);
You can do this purely inline if you want, but the expression of this is a bit confusing if you don't understand closures1. The advantage of this approach is that the name of the handler does not pollute the scope of the function in which you add the event listener.
addEventListener("theEvent", (function () {
function handler () {
/* ... */
removeEventListener("theEvent", handler);
};
return handler;
}()));
1Of course, if you don't understand closures then you should immediately go learn about them before writing another line of JavaScript, since this is one of the most useful and powerful features in the language.