Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

326
Visualizações
Could someone explain what the 'event' object actually is and how it works on a technical level?

I was wondering if someone could elaborate on what the event object actually is. I have looked at many sources that all seem to say it is an object that holds information about the current event.

My question is, what is it really? Is it a single global object that holds every event type? Or is there an event object for each unique event that occurs. I have seen in code you can write things like event.type, event.cancelBubble etc. does this mean I can access the event anytime and modify it from anywhere in the code? I have seen in examples of functions accepting an event as an argument, but why should this be if it is a global variable accessible anywhere?

I know this seems a bit broad but most sources seem to not go too much into how the event object works on a lower level. So if someone could clear this confusion for me that would be appreciated.

about 4 years ago · Juan Pablo Isaza
2 Respostas
Responde à pergunta

0

You are referring to the Window.event, which is no longer recommended for use. It is from a time when JavaScript had simpler goals and looser scope.

The read-only Window property event returns the Event which is currently being handled by the site's code. Outside the context of an event handler, the value is always undefined.

For new code, do not rely on the 'global' event being available and instead use the Event object passed to the event handler.

about 4 years ago · Juan Pablo Isaza Relatório

0

event is something that signifies something has happened.

If you click,type,resize, something loads etc. all of these are events. When you have a listener on any of these events, you are telling that you want something to happen in reaction to this event. The listener function has an argument event. This event will have details about the event that triggered it.

All these events implement from the same Event interface. So that is what you might be confusing it with. A bunch of event types - MouseEvent, ClipboardEvent etc. implement this. And events like click,dbclick,keyup etc. are then events using these interfaces. So it is like a chain you see. The properties you mentioned might belong to any of the interface at top level and are available at these specific events.

Note, you can create events too. This is helpful when you want to trigger events on your own. You can start with new Event().

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda