Variable Naming Rules
Variable Naming Rules: The Do’s and Don’ts
JavaScript has specific rules for naming variables. Follow these to avoid errors and write clean code!
What’s Allowed
- Letters (a-z, A-Z)
- Digits (0-9)
- Underscore (_)
- Dollar sign ($)
- Must start with a letter, underscore, or dollar sign
Valid Variable Names
Copy to Clipboard
Invalid Variable Names
Copy to Clipboard
Reserved Words to Avoid
let,const,varfunction,return,if,elsefor,while,doclass,import,export
Naming Conventions
- camelCase:
firstName,userAge - PascalCase:
UserProfile,CarModel - UPPER_CASE:
MAX_SIZE,PI - snake_case:
user_name,first_name
Tip: Choose a style and stick to it consistently in your project!