set time between two java script execution code example
Example 1: time taken for a function javascript
console.time("timer"); //start time with name = timer
console.timeEnd("timer"); //end timer and log time difference
Example 2: javascript settimeout
// Redirect to index page after 5 sec
setTimeout(function(){ window.location="index"; },5000);