This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var executionTimes = []; // an array to hold the time stamps at various stages, during callbacks | |
// this function simulates an async function to get the X value | |
function getXValue(callback) { | |
var num = ~~(Math.random() * 100); //get a number between 0-100 and coerce to an Integer using '~~' | |
console.log('X will be: ', num); | |
var delay = ~~(Math.random() * 5000); // set a random delay btw 0-5 sec | |
console.log('X Delay (in ms): ' + delay); | |
//now we set a timeout to invoke to callback function |