Lodash String Case Method Examples

Locash library contains several functions that work with the case of words.
  • _.camelCase
  • _.capitalize
  • _.kebabCase
  • _.lowerCase
  • _.upperCase
Learn Lodash JS at Lodash JS Tutorial with Examples.

Lodash String Case Method Examples

<!DOCTYPE html>
<html>
<head>
    <title>Lodash Tutorial</title>
    <script src="https://cdn.jsdelivr.net/npm/lodash@4.17.11/lodash.min.js"></script>

    <script type="text/javascript">
  const words = ["sky", "Sun", "Blue Island"];

  console.log(_.map(words, _.camelCase));
  console.log(_.map(words, _.capitalize));
  console.log(_.map(words, _.kebabCase));
  console.log(_.map(words, _.lowerCase));
  console.log(_.map(words, _.upperCase));
    </script>
</head>
<body></body>
</html>
Output:
[ 'sky', 'sun', 'blueIsland' ]
[ 'Sky', 'Sun', 'Blue island' ]
[ 'sky', 'sun', 'blue-island' ]
[ 'sky', 'sun', 'blue island' ]
[ 'SKY', 'SUN', 'BLUE ISLAND' ]

Reference

Comments