class Bases {
getData() {
// get some data and return
data = 'hello';
return data;
}
process() {
let greeting = this.getData();
console.log(greeting);
}
start() {
setInterval(this.process, 5000)
}
}
let b = new Bases;
b.start();
I want to call function 'process' so that it prints 'hello' every 5 seconds, however when i call b.start(), i always get this error:
TypeError: this.getData() is not a function
When i call b.process() instead of b.start() it works, but calling it in an interval always gives me the error. Any help is appriciated