Programming with JavaScript
What is control flow?
- Control Flow is the order in which the computer executes statements in a script
- Code is run in order (First line to Last line) unless it runs across conditionals and loops (They can change the control flow)
What is a JavaScript function?
- A block of code designed to perform a particular task, executed when “something” invokes it (calls it)
- “commmand”
What does it mean to invoke - or call - a function
- It’s a way to start the code inside a function. (Have it do its job)
What are the parenthesis () for when you define a function?
- Invokes the function
- Without the
() you might return the function not the function result
My own notes
function functionName(parameter1, parameter2, parameter3) {
// code to be executed
}
- Functions can be used similar to variables, if you declare a variable inside a function it can only be used inside that function (It’s Local)
<script src="script.js"></script>