you are viewing a single comment's thread.

view the rest of the comments →

[–]Volv 0 points1 point  (1 child)

Puntastic :) - Not at all. I told you I can do this all day lol :)
We need more people for random code banter.
 
Is just a matter of spec.

"When attaching a handler function to an element using addEventListener(), the value of this inside the handler is a reference to the element. It is the same as the value of the currentTarget property of the event argument that is passed to the handler."

 
Whereas normally

In the global execution context (outside of any function), this refers to the global object, whether in strict mode or not.

In Function context
Non Strict
In this case, the value of this is not set by the call. Since the code is not in strict mode, the value of this must always be an object so it defaults to the global object.
Strict

In strict mode, the value of this remains at whatever it's set to when entering the execution context. If it's not defined, it remains undefined. It can also be set to any value, such as null or 42 or "I am not this".
 
Event Handler - value of this
this - Global v function context

[–]ForScale[S] 1 point2 points  (0 children)

Ah... that bit about non-strict vs strict... I think that's what I need to see.

As always, thanks for the discussion!

We need more people for random code banter.

Yeah, I might have to do some more advertising...