run method over time and end js 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: how to do a function after a set interval js
function sayHi() {
alert('Hello');
}
//Do a function at a set interval continuously
setTimeout(sayHi, 1000);
//Do a function once after a set interval
setTimeout(sayHi, 1000);