One of the useful features of lodash library is the _.construtor
function, which can initialize objects given their prototype. Here's an example usage:
index.tsx330 chars15 lines
In this example, we define a prototype for our objects, Person
, which has some properties and a method. We then use lodash's _.constructor
function to create a new object based on that prototype. Finally, we set some properties on the newly created object and call its greet
method.
Note that you can also pass an object as a second argument to the _.constructor
function to initialize properties on the newly created object.
gistlibby LogSnag