In order to use the partialRight()
function from the lodash library in Typescript, you first need to install the Lodash library and its type definitions using NPM:
index.ts56 chars3 lines
After that, you can import partialRight()
function from lodash using the following statement:
index.ts39 chars2 lines
Once you have imported the function, you can use it to partially apply arguments to the rightmost side of a function in the following way:
index.ts247 chars8 lines
In the above example, we have defined a function greet()
that takes three arguments and returns a concatenated string. We have then used partialRight()
to create a new function greetMs()
that already has the value 'Ms.'
applied to the last parameter of greet()
. As a result, we only need to provide firstName
and lastName
to greetMs()
to get the result "Ms. Jane Doe!"
.
I hope this helps!
gistlibby LogSnag