To use the now function from the Underscore library in JavaScript, you can simply call it like this:
index.tsx9 chars2 lines
This function returns the current timestamp (in milliseconds since the Unix epoch). It can be useful for timing events or measuring performance.
Here's an example of using the now
function to time a function:
index.tsx213 chars11 lines
In this example, myFunction
calls _.now()
to get the start time, does some work, calls _.now()
again to get the end time, calculates the elapsed time, and logs it to the console.
gistlibby LogSnag