Short circuiting with booleans
Short Circuiting
Stopping of execution of boolean operation if the truth value of expression has been determined already.
Practice Short Circuiting
Variables
Variable
A variable is a named memory location (box) that contains a value (in the box) and can be used in expressions.
Assignment
Execution Rule
- Evaluate all expressions to the right of = from left to right.
- Bind all names to the left of = to those resulting values.
Example
Do not name your variables as built-in function names
E.g. sum, max, etc.
Functions
A function takes as input one or more arguments, computes a new value, a string or a number, and returns the value, so that it can be assigned to a variable or output.
Parameters vs. Arguments
The arguments are the data you pass intoo the function’s parameters.
Control Flow
- Reading the function definition without executing
- Seeing a “call” to the function, jumping up to the start of the function and executing
- Returning back to the place in the program that called the function and continuing.