Skip to main content

camelize

camelize converts a string into camelCase. It lowercases the first word, capitalises the first letter of every subsequent word and strips out any whitespace.

This is useful when you need to turn human-readable labels or hyphenated/spaced strings into valid JavaScript property or key names.

Usage examples

Basic

window.BAO.utils.camelize('hello world') // 'helloWorld'
window.BAO.utils.camelize('Add to cart') // 'addToCart'