![]() |
In JavaScript, console.time and console.timeEnd are powerful tools used for performance measurement. These methods allow developers to measure the time a block of code takes to execute, which is particularly useful for optimizing performance and debugging. Table of Content What is console.time?The console.time is a method used to start a timer. This timer is identified by a unique label which we provide as the parameter to the method. The timer runs until we call the console.timeEnd with the same label. Syntax:
Example: The example below shows console.time.
Output myTimer: 3ms What is console.timeEnd?The console.timeEnd is the method used to the stop the timer that was started with the console.time. It also takes the label of the timer as a parameter. When called, it logs the time elapsed since console.time was called with the same label. Syntax:
Example: The example below shows the console.timeEnd
Output myTimer: 2.562ms Difference Between console.time and console.timeEnd in JavaScriptThe table below shows the difference between console.time and console.timeEnd in JavaScript
|
Reffered: https://www.geeksforgeeks.org
Difference Between |
Type: | Geek |
Category: | Coding |
Sub Category: | Tutorial |
Uploaded by: | Admin |
Views: | 21 |