To use the lastIndexOf
function from the Underscore library in TypeScript, you will need to import the Underscore library as follows:
index.ts33 chars2 lines
Then, you can use the lastIndexOf
function to find the last index of a specified value in an array, as follows:
index.ts127 chars4 lines
In the code above, we imported Underscore library and assigned it to a variable _
. Then, we created an array and assigned it to a variable 'arr'. We called the lastIndexOf
function, passing in the arr
array and the value we want to find the last index of which is '3'. The function returns the last index of the specified value in the array.
gistlibby LogSnag