How does JS make the internal this of the callback function point to undefined?

my goal is to make the this of the content of the callback function point to undefined, but it is not necessary when the call method is passed into null or undefined. The internal this of the callback function is still a window object. Please give me some advice.

in addition, if you can force the callback function to use strict mode. How to achieve it? Or can it be realized?


the following code

var f = function(){
  console.log(this);
}
f.call(undefined);

in strict mode:
output 'undefined'

in non-strict mode,
outputs global objects

In

strict mode, those pointing to global objects point to undefined.


after reading the comments, I don't understand what you mean.
strict mode defaults to undefined , as follows

  

strict mode defaults to undefined , and non-strict is a window object.

Menu