It's because class
code is always strict code. From the spec
NOTE A class definition is always strict code.
Since class
code is always strict, the method log
is a strict function (so amongst other things, its internal [[ThisMode]] slot is set to strict
), and when you call a strict function without setting this
, this
is set to undefined
for the call.
The chain of operations in the spec that sets this up is that a direct call expression is evaluated by eventually calling the spec's abstract EvaluateDirectCall operation with thisValue set to undefined
. That in turn calls Call passing along the thisValue, which calls [[Call]] on the function passing thisValue as thisArgument, which calls OrdinaryCallBindThis, which checks the function's [[ThisMode]] and, if it's strict
, sets the thisValue to thisArgument directly without further logic (whereas if it weren't strict, it would replace null
and undefined
with the global object and do ToObject on any other values).