To use the bind
function from the Lodash library in TypeScript, you'll first need to install Lodash:
19 chars2 lines
Then, you can import the bind
function from Lodash and use it in your TypeScript code:
index.ts230 chars9 lines
In the example above, we're using the bind
function to create a new function sayHelloToJohn
that calls the sayHello
function with null
as the context, 'Hello' as the first argument, and 'John' as the second argument. We can then call sayHelloToJohn
without passing any arguments and it will log 'Hello, John!'.
gistlibby LogSnag