A script is a series of instructions that a computer can follow one-by-one. Each individual instruction or step is known as a statement. Statements should end with a semicolon.
COMMENTS
You should write comments to explain what your code does. They help make your code easier to read and understand. This can help you and others who read your code.
WHAT IS A VARIABLE?
A script will have to temporarily store the bits of information it needs to do its job. It can store this data in variables.
Variables: how to declare them
Before you can use a variable, you need to announce that you want to use it. This involves creating the variable and giving it a name. Programmers say that you Declare the variable.
Variables: how to assign them a value
Once you have created a variable, you can tell it what information you would like it to store for you. Programmers say that you assign a value to the variable.
DATA TYPES
JavaScript distinguishes between numbers, strings, and true or false values known as Booleans.
1- NUMERIC DATA TYPE: The numeric data type handles numbers.
2- STRING DATA TYPE: The strings data type consists of letters and other characters.
3- BOOLEAN DATA TYPE Boolean data types can have one of two values: true or false.
ARRAYS
An array is a special type of variable. It doesn’t just store one value; it stores a list of values.
CREATING AN ARRAY
You create an array and give it a name just like you would any other variable (using the var keyword followed by the name of the array).
The values are assigned to the array inside a pair of square brackets, and each value is separated by a comma. The values in the array do not need to be the same data type, so you can store a string, a number and a Boolean all in the same array.
Values in an array are accessed as if they are in a numbered list. It is important to know that the numbering of this list starts at zero (not one).
OPERATORS
Expressions rely on things called operators; they allow programmers to create a single value from one or more values.
JavaScript contains the following mathematical operators, which you can use with numbers. You may remember some from math class.
STRING OPERATOR
There is just one string operator: the+ symbol. It is used to join the strings on either side of it.