Variable part, 4

JavaScript Tutorial
Basic Concepts
Variables
34
4/5
               

Naming Variables



JavaScript variable names are case-sensitive. 
In the example below we changed x to uppercase:
var x = 100;
document.write(X);
Try It Yourself

This code will not result in any output, as x and X are two different variables.

Naming rules:
- The first character must be a letter, an underscore (_), or a dollar sign ($). Subsequent characters may be letters, digits, underscores, or dollar signs.
- Numbers are not allowed as the first character.
- Variable names cannot include a mathematical or logical operator in the name. For instance, 2*something or this+that;
- JavaScript names must not contain spaces.
Hyphens are not allowed in JavaScript. It is reserved for subtractions.
What characters can be used to start a variable?
Select all that apply
Underscore sign (_)
Letters
Numbers
Mathematical operators

Comments

Popular posts from this blog

Introducing object part 3

Comparison Operators part 2

Module 2