To use the first
function from the Lodash library in JavaScript, first you will need to import it into your code.
You can do this by installing Lodash via npm or yarn:
index.tsx19 chars2 lines
or
index.tsx16 chars2 lines
Then, in your JavaScript file, you can import the first
function from Lodash like this:
index.tsx32 chars2 lines
Once you have imported the first
function, you can use it to return the first element of an array like this:
index.tsx104 chars4 lines
Alternatively, you can also use the array method slice()
to achieve the same result:
index.tsx111 chars4 lines
gistlibby LogSnag