Class 1/20 Flashcards

1
Q

What are the five parts of a function definition?

A

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 well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

How do you call a function?

A

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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What is the difference between a parameter and an argument?

A

Function parameters are the names listed in the function definition.

Function arguments are the real values passed to (and received by) the function.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What does strictly equal mean?

A

The strict equality operator (===) checks whether its two operands are equal in TYPE and VALUE, returning a Boolean result.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What does strictly equal mean?

A

The strict equality operator (===) checks whether its two operands are equal, returning a Boolean result. equal value and equal type

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What is the logical and operator?

A

The AND operator (&&) returns true if both expressions are true, otherwise it returns false.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

When is the first expression in the parentheses for a for loop (known as the initialization) evaluated?

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

When is the second expression in the parentheses for a for loop (known as the condition) evaluated?

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What is the purpose of the condition in a for loop?

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

When is the third expression in the parentheses for a for loop (known as the final expression) evaluated?

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What is the purpose of the final expression in a for loop?

A

Often statement 3 increments the value of the initial variable. Generally used to update or increment the counter variable.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly