Control flow
Control flow means that when you read a script, you must not only read from start to finish but also look at program structure and how it affects order of execution.
The control flow is the order in which the computer executes statements in a script.
*Code is run in order from the first line in the file to the last line, unless the computer runs across the (extremely frequent) structures that change the control flow, such as conditionals and loops. *
for mre about control flow
JavaScript Functions
A JavaScript function is a block of code designed to perform a particular task.
A Function is much the same as a Procedure or a Subroutine, in other programming languages.
The code inside the function will execute when “something” invokes (calls) the function:
- When an event occurs (when a user clicks a button)
- When it is invoked (called) from JavaScript code
- Automatically (self invoked)
When JavaScript reaches a return statement, the function will stop executing.
If the function was invoked from a statement, JavaScript will “return” to execute the code after the invoking statement.
Functions often compute a return value. The return value is “returned” back to the “caller”
# Why Functions?
You can reuse code: Define the code once, and use it many times.
You can use the same code many times with different arguments, to produce different results.
### for more about function
# JavaScript Operators
-
Arithmetic Operators : Arithmetic operators are used to perform arithmetic on numbers
- Assignment Operators : Assignment operators assign values to JavaScript variables.
- String Operators : The + operator can also be used to add (concatenate) strings.
If you add a number and a string, the result will be a string!
- Comparison Operators : Comparison operators are used in logical statements to determine equality or difference between variables or values.
-
Logical Operators : Logical operators are used to determine the logic between variables or values.
- Conditional (Ternary) Operator : JavaScript also contains a conditional operator that assigns a value to a variable based on some condition.
variablename = (condition) ? value1:value2