let name = 'codedamn'; const yearFounded = 2015; var isAwesome = true;
Use clear and descriptive names
A variable name should be clear and descriptive enough to indicate what it holds. The name should specify what the variable means and what purpose it serves in the code.
// Bad Practice let a = 'codedamn'; let y = 2015; // Good Practice let platformName = 'codedamn'; let yearFounded = 2015;
Use camel casing
// Correct let numberOfUsers = 5000; // Incorrect let number_of_users = 5000; let NumberOfUsers = 5000;
Start names with a lowercase letter
// Correct let firstName = 'John'; // Incorrect let FirstName = 'John';
Avoid starting names with special characters or numbers
// Incorrect let 1name = 'John'; let $name = 'John'; let _name = 'John'; // Correct let name = 'John';
Q: What should I do if I have to use a variable name that's already taken?
You can append or prepend words to make the variable name unique. However, the new name should still be descriptive and adhere to the best practices discussed above.
Free money-back guarantee
Unlimited access to all platform courses
100's of practice projects included
ChatGPT Based Instant AI Help (Jarvis)
Structured Full-Stack Web Developer Roadmap To Get A Job
Exclusive community for events, workshops
Sharing is caring
Did you like what Mehul Mohan wrote? Thank them for their work by sharing it on social media.
No comments so far
Leave a question/feedback and someone will get back to you