About arrow pointing function in this

es6 pointing arrow and function in this general this is still a difference, it is time to create a determined,

In fact, I found an arrow pointing function is console.log (this) at the same level in this, so you can understand relatively simple questions directed at multiple levels of nested function in this case the arrow of the

var f1 = {
        f2: {
            f3: {
                f6: console.log(this),//window
                f4: () => console.log(this)
            }
        }
    };
    f1.f2.f3.f6;//window

Equivalent, a delegation of console.log (this) is not at the same level f4 arrow pointing function in this

Coupled with a Code

var Test = () => { 
    the console.log ( the this II.A); 
} 
// formally equivalent to 
var Test = function () { 
    the console.log ( the this II.A); 
} 
// substantially equivalent to the 
function Fn () {
     var that = the this ;
     var Test = function () { 
        the console.log (that.a); 
    } 
}

The test which is equivalent to the function of the arrow, then inside it and it is this same level of this, both console.log (this) inside this a

Guess you like

Origin www.cnblogs.com/WildSky/p/11246693.html