The console output is inconsistent with the js file output (event.currentTarget gets null)

Code:

console.log(e);
console.log(e.currentTarget);
The result of

is:

VM1656:1 MouseEvent{isTrusted: true, screenX: 149, screenY: 253, clientX: 149, clientY: 131,}
VM1656:2 null

obviously, the event object is the same, but why is the console output currentTarget null ?

look at currentTarget in the event object from the console, and its value is null , so why is the currentTarget output in the js file not null ?


according to W3C specification:

https://www.w3.org/TR/DOM-Lev.

currentTarget -Used to indicate the EventTarget whose EventListeners are currently being processed. This is particularly useful during capturing and bubbling.

currentTarget is used during event being processed .

try the following code:

  

you only typed the last two sentences in the console. Obviously, the main body is incorrect. The previous event was captured during execution, but the last one is not the same thing. To put it simply, the context is different.

Menu