Programming Tips - javaScript: What's a compact way to time the duration of something in javaScript?

Date: 2009dec21 Language: javaScript Q. javaScript: What's a compact way to time the duration of something in javaScript? A. Here's an example:
// Returns milliseconds since 1970 function getTime() { return new Date().getTime(); } function exampleUse() { const start = getTime(); // Do something const duration = getTime() - start; }