It's hard to explain my question, so I'm posting some code.
function caller(func) {
function printMessage(message) {
console.log(message);
}
func();
}
function callee() {
printMessage('hello world');
}
caller(callee);
I want to access printMessage from callee, but as it currently stands, this throws a ReferenceError. I'd like to avoid declaring printMessage globally, if possible.
Aucun commentaire:
Enregistrer un commentaire