function download(done) {
setTimeout(function () {
console.log("Wait is over...");
done("downloaded the game..");
}, 10000);
}
download(function (message) {
console.log(message);
});
the above works as intended
but when i change the anonymous function to just a normal function the output isnt the same i.e. the delay is not there!!! why???
function callme(done) {
console.log("Wait is over...");
done("downloaded the game..");
};
function download(done) {
setTimeout(callme(done), 10000);
};
download(function (message) {
console.log(message);
});
basically in the second code i changed the anonymous function to a new callme function…