cover-img

Naming Variables in JavaScript

20 March, 2024

40

40

0

Contributors

There are a few rules that we must follow to ensure that we don't break our code.

  1. There can be no spaces or dashes in our code names.
    • Names like let first name = ... or let first-name = ... are not viable.
  2. Names must begin with a letter of the alphabet -> a-z, A-Z.
    • Best practice in JS is to start your variables with a lowercase letter e.g. let name = ... as opposed to let Name = ....
  3. For multi-word variables, we use either the camelCase or snake_case.
    • camelCase capitalizes the first letter of each word in a phrase, without using spaces or punctuation (with exception to the first word).
    • snakecase is a way of writing phrases without spaces, where spaces are replaced with underscores ``, and the words are all lower case.

So the correct way to write the first name example above would be:

  • let firstName = "Arnob" or let first_name = "Arnob"

40

40

0

Arnob
i build web apps

More Articles

Showwcase is a professional tech network with over 0 users from over 150 countries. We assist tech professionals in showcasing their unique skills through dedicated profiles and connect them with top global companies for career opportunities.

© Copyright 2025. Showcase Creators Inc. All rights reserved.