Loops

Loops are a very valuable resource for developers. It allows you to repeat code many times over without having to type it out each time. Given the right variables you can make slight changes to each iteration

For

The for loop is great for iterating through arrays as you increase the index number. It takes three statements: first is usually for initializing variables, second is for adding a condition for when to stop the loop, the last statement is used for changing the index value. each statement is optional

For/in

The for in loop is great for objects or associative arrays. It is also has a very clean fill to them

While

The while loop is similar to the for loop, except that it only takes the conditional statement and does not set variables or change them.

Do While

The do while is unique among the loops as it will always run the code at least once.

Conditional

if

The if condition is used to test a value and display the code within if it is true. The example below states if variable i is equal to 3

else

The else condition is like an add on to the if condition. If the first statement is false then the else code is used. It works great for error messages, you can make it so anything but what you have in the if condition returns an error

else if

the else if statement is another add on to the if condition. When used, it comes before the else statment. Unlike the if and else, the else if statment can be used multiple times. Like the if condition, each of the else if needs a condition to check

switch

The switch condition is similar to the construction of the if, else if and else. The difference is there is only one variable that is checked over multiple conditions. It has a default case that is like the else portion of the other condition statement.

Statements

Statements include variables and keywords. It is important to use semicolons at the end of the statement. white spaces and linebreaks can be added for code readability. Statements can be placed in blocks with functions. Keywords include break, continue, return and more

Functions

As stated above functions allow code to be put in blocks. It allows the code to be reused.

Variables

I have used variables allthroughout my Javascript, they works a lot like Algebra. "A + B = C" Setting variables is as easy as using a single equals sign. They also need the "var" when the variable is first created.

Parameters

Parameters are often used with functions. They allow flexability in the variable values in the code block. I have used different values for the function used before.

Arrays

Arrays are often refered to as buckets of variables. It connects data together. They are great for similar information, like first name and last name. All the values have an index number connected with it; starting at 0.

Associative Arrays

Associative arrays are arrays that use names for indexes rather than numbers