I don't understand the use of the general word callback. I am investigating a big JS code and in the same class I have these two functions, both using callback but I can't get which function will be called back...I guess I'm missing a basic knowledge about callbacks.. can someone explain please..
My example is general, I need to understand the idea of using callback what will be the next step, my code works I just need to understand it...
getNames(callback: (Names: name[]) => void, Name:string) {
Names = ['david','elton','eliza']
callback(Names);
});
}
getFood(callback: (Foods : Food []) => void, Food:string) {
Foods = ['egg','bacon','chicken']
callback(Foods);
});
}