Thursday, October 23, 2025
HomeLanguagesJavascriptLodash _.camelCase() Method

Lodash _.camelCase() Method

Lodash _.camelCase() method is used to convert a string into a camel case string. The string can be space-separated, dash-separated, or can be separated by underscores.

Syntax:

_.camelCase(string);

Parameters:

  • string: This parameter holds the string that needs to be converted into a camel case string.

Return Value:

This method returns the camel case string

Example 1: In this example, we are changing the string which is space-separated and dash-separated into the camel case using the _.camelCase() method.

Javascript




// Requiring the lodash library
const _ = require('lodash');
 
// Use of _.camelCase() method
let str1 = _.camelCase("Geeks for Geeks");
 
// Printing the output
console.log(str1);
 
// Use of _.camelCase() method
let str2 = _.camelCase("GFG-Geeks");
 
// Printing the output
console.log(str2);


Output:

neveropenForGeeks
gfgGeeks

Example 2: In this example, we are changing the string which is underscore-separated into the camel case using the _.camelCase() method.

Javascript




// Requiring the lodash library
const _ = require('lodash');
 
// Use of _.camelCase() method
let str1 = _.camelCase("Geeks__for__Geeks");
 
// Printing the output
console.log(str1);
 
// Use of _.camelCase() method
let str2 = _.camelCase("GFG--Geeks");
 
// Printing the output
console.log(str2);


Output:

neveropenForGeeks
gfgGeeks
Whether you’re preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape, neveropen Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we’ve already empowered, and we’re here to do the same for you. Don’t miss out – check it out now!
Dominic
Dominichttp://wardslaus.com
infosec,malicious & dos attacks generator, boot rom exploit philanthropist , wild hacker , game developer,
RELATED ARTICLES

Most Popular

Dominic
32361 POSTS0 COMMENTS
Milvus
88 POSTS0 COMMENTS
Nango Kala
6728 POSTS0 COMMENTS
Nicole Veronica
11892 POSTS0 COMMENTS
Nokonwaba Nkukhwana
11954 POSTS0 COMMENTS
Shaida Kate Naidoo
6852 POSTS0 COMMENTS
Ted Musemwa
7113 POSTS0 COMMENTS
Thapelo Manthata
6805 POSTS0 COMMENTS
Umr Jansen
6801 POSTS0 COMMENTS