Junior
How can the execution speed of a code segment be measured using the Date.now method?
sobes.tech AI
Answer from AI
const startTime = Date.now();
// Your code to measure
const endTime = Date.now();
const duration = endTime - startTime; // Duration in milliseconds
console.log(`Execution time: ${duration} ms`);