In JavaScript, a variable name:

  • Can begin with a letter, underscore (_) or dollar sign ($);
  • Can only contain letters, numbers, underscores, or dollar signs;
  • Cannot be the same as a JavaScript reserved word;
  • Cannot contain spaces;
  • Is case-sensitive.

For example, the following are all valid variable names:

const foo = 'bar';
const $foo = 'bar';
const _foo = 'bar';
const _123foo = 'bar';
const foo_bar123$ = 'bar';
const fooBar = 'bar';