let a = () => (
{
name:"Anna",
func: () => console.log(this.name)
}
)
let b = () => (
{
name:"Brian",
func: function(){ console.log(this.name) }
}
)
let c = function(){
return(
{
name:"Charlie",
func: function(){ console.log(this.name) }
}
)
}
let d = function(){
return(
{
name:"Denny",
func: () => console.log(this.name)
}
)
}
These 4 functions have mix & matched function syntax. When calling the nested function, the func: with arrow function returns blanks.
a().func() // returns blank
b().func() // returns "Brian"
c().func() // returns "Charlie"
d().func() // returns blank
I thought the arrow function retain the scope of "this"? The behavior seems to be the opposite of what I've thought. When did the arrow function went out of scope?