Consider this javascript:
let m = {
add: (a,b) => a+b,
subtract: (a,b) => a-b,
doit: () => console.log(this.add(5,4)),
};
m.doit();
When I run this code, I get the following error:
doit: () => console.log(this.add(5,4)),
^
TypeError: this.add is not a function
What is the proper way to call the add
function from within doit
?