Pilcrow Records

Scripter Javascript Tutorial

javascriptmusiclogicscripterbookexcerpttutorial

14 Allowed Characters

MDN: Grammar and types: Variables

Variables have a few rules when naming:

  1. The variable name can only contain letters, numbers, the symbol “$” (dollar sign), and the symbol “_” (underscore).

  2. The first character cannot be a number.

  3. Variable names are case sensitive.

The following are examples of valid variable names:

var activeNotes;
var beats_per_bar;
var note1;
var \$;
var ActiveNotes; // begins with a capital letter, so it's a new variable.

The following are examples of invalid variable names:

var 2nd_note;
var beats-per-bar; // hyphens aren't allowed