Skip to content

toCamelCase

Converts a string to camelCase format.

Syntax

typescript
toCamelCase(str: string): string

Parameters

ParameterTypeDescription
strstringThe input string.

Returns

TypeDescription
stringThe string converted to camelCase.

Example

typescript
toCamelCase("exemplo de string"); // "exemploDeString"
toCamelCase("  teste camel case  "); // "testeCamelCase"
toCamelCase(""); // ""

Notes

  • Throws TypeError if the argument is not a string.
  • Extra spaces are removed before conversion.

References

Released under the MIT License.