I have defined a function which returns object which has property and a method. using the returned object I am calling the method inside the object to get the value of the property in the object. but I didn't received what I expected.
function test(){
return {
a:'test property',
fn:()=>{
console.log('property', this.a);
}
}
}
const obj = test();
obj.fn() // what I expect is test property but I received undefined.

When you use a regular function
thisis scoped to how it is called. exampleobjis taken as yourthiswhen you define using arrow function
thisis assigned on creation which points to the parent's context in your case itswindow