Reading-Notes
My journal for Code Fellows
Project maintained by RogerMReyes
Hosted on GitHub Pages — Theme by mattgraham
Programming with JavaScript Lab 07
Control Flow
- Control flow is the order in which your computer executes statements in a script
- Scripts use condition structures such as
JavaScript Function
- A function is a block of code designed to perform a particular task
- It executes whe something invokes/calls it
- It is defined by a
function
keyword followed by ()
- Inside the parentheses may be parameters
- The code to be executed is placed inside curly brackets following the parentheses
- Function can be called three different ways
- When an event occurs (user action)
- When it is called in the code
- When it is set to be self invoked
- Function
return
will return whatever value the code executes back to the statement
- You can define the code once and use it multiple times
- Variable declared within a function are Local Variables and can only be referenced within the function
JavaScript Operators
Arithmetic Operators
+ Addition
- Subtraction
* Multiplication
** Exponentiation (ES2016)
/ Division
% Modulus (Division Remainder)
++ Increment
-- Decrement
Assignment Operators
= |
x = y |
x = y |
+= |
x += y |
x = x + y |
-= |
x -= y |
x = x - y |
*= |
x *= y |
x = x * y |
/= |
x /= y |
x = x / y |
%= |
x %= y |
x = x % y |
**= |
x **= y |
x = x ** y |
Comparison Operators
== equal to
=== equal value and equal type
!= not equal
!== not equal value or not equal type
> greater than
< less than
>= greater than or equal to
<= less than or equal to
? ternary operator
Logical Operators
&& logical and
|| logical or
! logical not
Return to Code 102 Table of Contents