Reading-Notes

View the Project on GitHub MohammadAl-khatib/Reading-Notes

Read07

Control Flow

When using JavaScript, the default way for reading your code is from top to bottom, but sometime you may want to manipulate this default, to do so, you can use functions and loops and if statements.

Functions (when declared but not when expressed) will make JavaScript skip the code under and search for the function and execute it, after that the program will continue from where it ended firstly.

For loops and if statements are condition dependant syntaxes, meaning whenever the condition is met, the staement will skip executing the syntax inside.  

Functions

Functions are block of codes that you can call where ever you need, functions can be declared or expressed. Declaring a functions makes it possible to use it anywhere in the file, while expressing a function will make possible to call it only after defining it.

Why to use functions?

  1. Save Time
  2. Shorter code
  3. Easier to call

How to use functions

The general form of defining a function is as follows image of JavaScript function As you can see, calling a function is essential to show the results.

Nested functions can be used also, but keep in mind that the variable of the inner function are only used for it and cannot be recognised by either the outer function or by the file.

Operators

Operators can be divided into:

each operator type deals with specific type of data and does different task, you can read more in details in the references below.

References: