0

I'm going through a JavaScript problem with this and I don't understand something.

function Cat(name) {
    this.name = name;
    inner();
    function inner() {
        //A
        console.log("A", this.name); // this is too long so had to use this.name
    }
    //B
    console.log("B", this);

    //C
    ( () => console.log("C", this) )();
}

var myCat = new Cat('Markov');

I don't understand how it prints the right value for ()=>{} arrow functions that's inside IFFE. Can someone enlighten me?

I thought the scope of this inside an IFFE with arrow would be window object :S

TechnoCorner
  • 4,879
  • 10
  • 43
  • 81

0 Answers0