In this example,
z are variables. Variables are declared with the
let x = 5; let y = 6; let z = 11;
For the example above, you can expect:
xstores the value 5.
ystores the value 6.
zstores the value 11.
Before 2015, using the
const keyword to define a variable that cannot be reassigned, and the
let keyword to define a variable with restricted scope.
This is why this course will not be using
var, but will be using
Identifiers can be short names (
y) or more descriptive names (
The general rules for constructing names for variables (unique identifiers) are:
- Names can contain letters, digits, underscores, and dollar signs.
- Names must begin with a letter.
- Names can also begin with $ and _ (but we will not use it in this tutorial).
- Names are case sensitive (y and Y are different variables).
- A letter (A-Z or a-z)
- A dollar sign ($)
- Or an underscore (_)
$ are valid variable names:
let $$$ = "Hello World"; let $ = 2; let $myMoney = 5;
$ is used to select HTML elements. In jQuery
$("p"); means "select all p elements".
_ are valid variable names:
let _lastName = "Johnson"; let _x = 2; let _100 = 5;
You can add practice problems here if you want. Follow the format below.