How to use 'javascript proper case' in JavaScript

Every line of 'javascript proper case' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your JavaScript code is secure.

All examples are scanned by Snyk Code

By copying the Snyk Code Snippets you agree to
this disclaimer
8function to_python_case(key) {
9 return key.replace(/([a-z])([A-Z]+)/g, function ($0, $1, $2) {
10 return $1 + '_' + $2.toLowerCase();
11 });
12}
Important

Use secure code every time

Secure your code as it's written. Use Snyk Code to scan source code in minutes – no build needed – and fix issues immediately. Enable Snyk Code

11export function startCase(string) {
12 if (string) {
13 return string
14 .replace(/[_-]/g, ' ')
15 .toLowerCase()
16 .replace(/(?:^|\s|-)\S/g, x => x.toUpperCase())
17 }
18}

Related snippets