Under what circumstances will this point to undefined?

here are two examples, one is a named function and the other is an anonymous function. Why are the results different

var a = {
    b: function b() {
        function a() {
            console.log(this.a);
        }
        a();
    }
};
a.b();// undefined
Mar.13,2021

anonymous functions should not affect the default this . What affects the default this is whether strict mode, uses use strit .


should all be {b: strict} maybe you are in strict mode

Menu