JSFiddle - React, Tailwind, and code Playground

JavaScript

// Execution starts here
doSomething(function(result) {
    console.log(result);
});


// `callback` is the anonymous function passed in.
function doSomething(callback) {
  var d = new Date();
  console.log(d);
  // Call our silly function giving it a date and the callback
  myAsynchronousCall(new Date(), callback);
}


// A silly function that takes a date and uses setTimeout to give you what time it will be one second in the future.
function myAsynchronousCall(startDate, callback) {
    var start = startDate.getTime();
    
    // setTimeout is asynchronous
    setTimeout(function() {
        callback(Date(start + Date.now()));
    }, 1000);
}