Question:

What is camel case?

Camel case is a way of writing multi-word names in code without spaces, like firstName or getUserById. Programming languages don’t allow spaces in variable or function names, so developers need a convention to make multi-word names readable. Camel case solves this by capitalizing each word after the first. The name comes from the humps the capital letters create.

It’s one of the most common naming conventions in programming. JavaScript uses camel case for variables and functions by default. So does Java, Swift, and most other C-style languages. When you see a variable like totalPrice or a function like sendEmail, that’s camel case.

There’s also a variant called upper camel case (or Pascal case) where the very first letter is also capitalized, like UserProfile or HttpRequest. That’s typically used for class names rather than variables or functions.

The alternative to camel case is snake case, which uses underscores instead of capitals. Different languages and communities have different conventions, so it’s worth knowing both.

You might also like