yodacom
5/9/2017 - 6:26 PM

wrappedSetTimeoutCallback created by yodacom - https://repl.it/HpFR/2

wrappedSetTimeoutCallback created by yodacom - https://repl.it/HpFR/2

// simple wrapping of setTimeout in my own wait function that accepts callback as 2nd argument. That callback gets called setTimeout after the Number of seconds passed in as the first argument to wait.

function wait(seconds, callback) {
  setTimeout(function(){
    callback(new Date());
  }, seconds * 1000);
}

console.log('Console log before calling wait:', new Date());

wait(3, function(date) {
  console.log('Console log inside anonymous callback:', date);
});

console.log('Console log after calling wait:', new Date());