To use the kebabCase
function from lodash in JavaScript, you'll need to follow these steps:
Install lodash using npm or yarn if it's not already installed, by running npm install lodash
or yarn add lodash
in your terminal.
Import the kebabCase
function into your JavaScript file, by adding the following line at the top of your file:
index.tsx36 chars2 lines
Use the kebabCase
function on a string to convert it to kebab case (i.e. with hyphens instead of spaces or underscores), like this:
index.tsx98 chars3 lines
The kebabCase
function also works on strings that use camel case or Pascal case, and will convert them to kebab case as well:
index.tsx227 chars5 lines
That's it! You've successfully used the kebabCase
function from lodash in your JavaScript code.
gistlibby LogSnag