I have a class that take in a function as a constructor parameter. Then I have class function that calls that function later on. The problem is that the function become undefined later on. I am not sure what is happening? Is it even doable? I double check and the saveFunction property is not being re-assign else where.
class myClass {
constructor(saveFunction ) {
this.saveFunction = saveFunction;
console.log(typeof this.saveFunction); // --> return function
}
saveClassData(saveData) {
console.log(typeof this.saveFunction); // --> return undefined
this.saveFunction(saveData);
}
}