Is there any way to remove the event handler inside the callback function immediately after?

element.addEventListener( 'mousedown', () => {
 window.addEventListener( 'mouseup', () => {
 //do something;
 //and here remove a handler on window until a next click on the element
 } );
} );
June 7th 19 at 14:54
1 answer
June 7th 19 at 14:56
Solution
addEventListener and removeEventListener
const onClick = () => {
 console.log("Hello World");
 window.removeEventListener('click', onClick);
});
window.addEventListener('click', onClick);

SyG did not notice the comment above.

Find more questions by tags JavaScript