es-toolkit/docs/reference/string/camelCase.md
2024-07-14 17:23:57 +09:00

695 B

camelCase

Converts a string to camel case.

Camel case is a naming convention in which the first word is in lower case and each subsequent word is capitalized. For example, camelCase.

Signature

function camelCase(str: string): string;

Parameters

  • str (string): The string that is to be changed to camel case.

Returns

(string) The converted string to camel case.

Examples

import { camelCase } from 'es-toolkit/string';

camelCase('camelCase'); // returns 'camelCase'
camelCase('some whitespace'); // returns 'someWhitespace'
camelCase('hyphen-text'); // returns 'hyphenText'
camelCase('HTTPRequest'); // returns 'httpRequest'