Class 1/20 Flashcards
What are the five parts of a function definition?
A JavaScript function is defined with the function keyword, followed by a name, followed by parentheses ().
Function names can contain letters, digits, underscores, and dollar signs (same rules as variables).
The parentheses may include parameter names separated by commas:
(parameter1, parameter2, …)
The code to be executed, by the function, is placed inside curly brackets: {}
How do you call a function?
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)
The () Operator Invokes the Function
What is the difference between a parameter and an argument?
Function parameters are the names listed in the function definition.
Function arguments are the real values passed to (and received by) the function.
What does strictly equal mean?
The strict equality operator (===) checks whether its two operands are equal in TYPE and VALUE, returning a Boolean result.
What does strictly equal mean?
The strict equality operator (===) checks whether its two operands are equal, returning a Boolean result. equal value and equal type
What is the logical and operator?
The AND operator (&&) returns true if both expressions are true, otherwise it returns false.
When is the first expression in the parentheses for a for loop (known as the initialization) evaluated?
Statement 1 is executed (one time) before the execution of the code block. An expression (including assignment expressions) or variable declaration evaluated once before the loop begins. Typically used to initialize a counter variable. This expression may optionally declare new variables with var or let keywords. Variables declared with var are not local to the loop, i.e. they are in the same scope the for loop is in. Variables declared with let are local to the statement.
When is the second expression in the parentheses for a for loop (known as the condition) evaluated?
Statement 1 is executed (one time) before the execution of the code block.
Statement 2 defines the condition for executing the code block.
Statement 3 is executed (every time) after the code block has been executed.
If statement 2 returns true, the loop will start over again, if it returns false, the loop will end.
What is the purpose of the condition in a for loop?
An expression to be evaluated before each loop iteration. If this expression evaluates to true, statement is executed. This conditional test is optional. If omitted, the condition always evaluates to true. If the expression evaluates to false, execution skips to the first expression following the for construct.
When is the third expression in the parentheses for a for loop (known as the final expression) evaluated?
An expression to be evaluated at the end of each loop iteration. This occurs before the next evaluation of condition. Generally used to update or increment the counter variable.
What is the purpose of the final expression in a for loop?
Often statement 3 increments the value of the initial variable. Generally used to update or increment the counter variable.