Skip to content
Related Articles
Open in App
Not now

Related Articles

Lodash _.camelCase() Method

Improve Article
Save Article
  • Last Updated : 09 Sep, 2020
Improve Article
Save Article

The _.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: This method accepts a single parameter as mentioned above and described below:

  • 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.

Below example illustrate the Lodash _.camelCase() method in JavaScript:

Example 1:

Javascript




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


Output:

geeksForGeeks
gfgGeeks

Example 2:

Javascript




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


Output:

geeksForGeeks
gfgGeeks
My Personal Notes arrow_drop_up
Related Articles

Start Your Coding Journey Now!