author avatar

adithya.hebbar

Tue Jun 25 2024

In JavaScript, console.time is a method that helps you measure the time it takes for a specific block of code to execute. It's like a stopwatch for your code.


// Start the timer 
console.time('myTimer');
for (let i = 0; i < 1000000; i++) { 
 // Some code here 
}
// Stop the timer 
console.timeEnd('myTimer');


So, when you run this code, you'll see something like: "myTimer: 1.358ms"

#javascript