how to use the now function from the underscore library in typescript

To use the now function from the underscore library in TypeScript, you first need to install the library:

npm install underscore
23 chars
2 lines

Then, in your TypeScript file, you can import the now function from the library like this:

index.ts
import * as _ from 'underscore';

const currentTime = _.now();
console.log(currentTime); // outputs the current timestamp in milliseconds
138 chars
5 lines

The now function returns the current timestamp in milliseconds using the Date object. You can use this function in your TypeScript project to get the current time or to measure the performance of parts of your code.

gistlibby LogSnag