Lodash - capitalize method


Advertisements

Syntax

_.capitalize([string=''])

Converts the first character of string to upper case and the remaining to lower case.

Arguments

  • [string=''] (string) − The string to capitalize.

Output

  • (string) − Returns the capitalized string.

Example

var _ = require('lodash');
var input = 'TutorialsPoint';
var result = _.capitalize(input);

console.log(result);

Save the above program in tester.js. Run the following command to execute this program.

Command

\>node tester.js

Output

Tutorialspoint
lodash_string.htm
Advertisements