The value to be converted to camelCased string
OptionalupperFirst: boolean
Optionally, uppercase the first character of the first word, so when true
this will produce a Pascal Cased result.
The camelCased version of the provided value.
strCamelCase(null); // "null"
strCamelCase(undefined); // "undefined"
strCamelCase("hello darkness"); // "helloDarkness"
strCamelCase("hello_darkness"); // "helloDarkness"
strCamelCase("_hello_darkness"); // "helloDarkness"
strCamelCase("hello-darkness"); // "helloDarkness"
strCamelCase("-hello-darkness"); // "helloDarkness"
strCamelCase("hello darkness, my old friend."); // "helloDarknessMyOldFriend"
strCamelCase("helloDarkness"); // "helloDarkness"
strCamelCase("HelloDarkness"); // "helloDarkness"
strCamelCase("café crème"); // "caféCrème"
// The case of the other letters is retained, so normalize the value first when required
strCamelCase("HELLO WORLD"); // "hELLOWORLD"
strCamelCase(strLower("HELLO WORLD")); // "helloWorld"
strCamelCase("XMLHttpRequest"); // "xMLHttpRequest"
strKebabCase("XMLHttpRequest"); // "xml-http-request"
strCamelCase(strKebabCase("XMLHttpRequest")); // "xmlHttpRequest"
// Uppercase first character
strCamelCase("hello darkness", true); // "HelloDarkness"
strCamelCase("hello_darkness", true); // "HelloDarkness"
strCamelCase("_hello_darkness", true); // "HelloDarkness"
strCamelCase("hello-darkness", true); // "HelloDarkness"
strCamelCase("-hello-darkness", true); // "HelloDarkness"
strCamelCase("hello darkness, my old friend.", true); // "HelloDarknessMyOldFriend"
strCamelCase("XMLHttpRequest", true); // "XMLHttpRequest"
strCamelCase(strLower("HELLO WORLD"), true); // "HelloWorld"
strCamelCase(strKebabCase("XMLHttpRequest"), true); // "XmlHttpRequest"
Convert the provided value to
camelCasedstring, you can optionally specify whether the first character is upper cased (lowercase by default).All separators (whitespace, punctuation and symbols, eg. spaces,
_and-) are removed and the first letter of each following word is uppercased (the separators are the punctuation and symbols of ASCII and Latin-1, exceptª²³µ¹º¼½¾, and of the General Punctuation, Currency Symbols, Arrows to Miscellaneous Symbols and Arrows, and CJK Symbols and Punctuation blocks, with the same exceptions as strLetterCase, so the emoji of these blocks are removed, eg."I ⭐ JS"is"iJS", all other characters such as😀and™are part of a word), the first letter of the result is lowercased (or uppercased whenupperFirstistrue). The case of all other letters is retained, so the conversion is reversible with strKebabCase / strSnakeCase (eg."helloDarkness"to"hello-darkness"and back to"helloDarkness") and an existing camelCase (or PascalCase withupperFirst) value is returned unchanged. Non-ASCII letters are retained, using the same fixed character ranges on every runtime. If the value is not a string it will be converted.