Not an anonymous option
element.funky = function() { console.log("Click!"); }; element.funky.type = "click"; element.funky.capt = false; element.addEventListener(element.funky.type, element.funky, element.funky.capt);
After receiving feedback from Andy (quite correctly, but, like in many examples, I wanted to show a context extension of the idea), here was a less complicated presentation:
<script id="konami" type="text/javascript" async> var konami = { ptrn: "38,38,40,40,37,39,37,39,66,65", kl: [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ] }; document.body.addEventListener( "keyup", function knm ( evt ) { konami.kl = konami.kl.slice( -9 ); konami.kl.push( evt.keyCode ); if ( konami.ptrn === konami.kl.join() ) { evt.target.removeEventListener( "keyup", knm, false ); document.body.classList.add( "konami" ); } }, false ); document.body.removeChild( document.getElementById( "konami" ) ); </script>
This allows for an efficiently anonymous functional structure, avoids the use of a virtually laid-back caller, and makes it easy to delete.
By the way:: removing the script element immediately after installing the listener is a nice trick to hide the code, which, perhaps, would not be completely obvious to prying eyes (spoils the surprise;)
So the method is (simpler):
element.addEventListener( action, function name () { doSomething(); element.removeEventListener( action, name, capture ); }, capture );