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

index.ts
import * as _ from "lodash";

const currentTime: Date = _.now();
console.log(currentTime);
91 chars
5 lines

Here, we use the import statement to import the lodash library. We then define a Date variable called currentTime which will hold the current date and time. We set its value using the _.now() function from lodash. Finally, we log the currentTime to the console to see the output.

Note that we use the import statement with the * syntax which means that we import everything from the lodash library. The now() function is then accessed through the _ namespace which is an alias we created for the entire lodash library.

gistlibby LogSnag