Use Camel Case in JavaScript - toolpage.org
CamelCase Converter

Use Camel Case in JavaScript

JJavaScript has no native function for converting strings to Camel Case. To convert individual strings or texts in your JavaScript programs to camel case notation, you can use our extensive CaseConverter library, which you can find on GitHub:

JS Case Converter
https://github.com/toolpage/php-case-converter

An example call embedded in a HTML page looks like this:

<!DOCTYPE html> <html> <head> <script src="caseconverter.js"></script> </head> <body> <script> var input = "The quick brown fox jumps over the lazy dog"; CaseConverter.convertToCamelCase(input); // TheQuickBrownFoxJumpsOverTheLazyDog </script> </body> </html>

CamelCase function for JavaScript

If you don't want to use our library and only need a small function, this function might help you:

function convertToCamelCase(value){ value = value.replace(/[\(\)\[\]\{\}\=\?\!\.\:,\-_\+\\\"#~\/]/g, " "); var returnValue = ""; var makeNextUppercase = true; value = value.toLowerCase(); for (var i = 0; value.length > i; i++) { var c = value.charAt(i); if (c.match(/^\s+$/g) || c.match(/[\(\)\[\]\{\}\\\/]/g)) { makeNextUppercase = true; } else if (makeNextUppercase) { c = c.toUpperCase(); makeNextUppercase = false; } returnValue += c; } return returnValue.replace(/\s+/g, ""); }

An example of use would be:

convertToCamelCase("Camel case notation"); // CamelCaseNotation

Other Implementations