JS Course 1: Fundamental 3 Flashcards

1
Q

What are functions useful for?

A

Functions are useful for achieving a single task without needing to rewrite the code to run a task over and over again.

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

What’s the difference between functions and methods?

A

Functions are a set of instructions th perform a single task and do not associate with methods.

Methods are like functions, but they specifically only associate with objects.

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

What are function parameters? What are optional parameters and default parameters?

A

Function parameters, or arguments, are values you apply to a function when invoking them. They are values needed to be included inside the function’s parentheses to do it’s job properly.

Optional parameters are function parameters that are not required for the function to run, but can be applied if needed.

Default parameters are function parameters that have preset/default settings or values (unless they’re reassigned.)

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

What are function arguments?

A

Function arguments, compared to function parameters, are the actual values passed through a function. Function parameters are the variables or other values to be used in the function, but function arguments are the actual values you pass into a function.

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

How do you invoke a function?

A

You invoke a function by calling the name in arguments or applying the function to a variable

Examples:
prompt(“You’re stupid”)

or

variable.Boolean()

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

What is function scope?

A

Function scope refers to the scope of variables that can only be seen inside a function.

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

What is Global Scope?

A

Global Scope refers to the variables that are retrievable on the outside of functions. In other words, everywhere on the page except for inside functions.

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

What are Local Variables

A

Local variables are variables inside a function that are inaccessible to the global scope.

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

What are Outer Variables?

A

Outer variables are variables that can be retrieved by functions outside of those functions, also called Global Variables.

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

What are return values?

A

Return values are the values returned after running a function.

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

What are anonymous functions?

A

Anonymous functions are functions that do not have a name. This is done with the syntax of function expression.

Syntax:
(function () {
alert(‘hello’);
})

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

What are arrow functions?

A

Arrow functions are functions created with an alternative, more compact syntax using the arrow symbol =>.

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

What are custom functions?

A

Custom functions are functions you can customize in your code. You can customize the job it does and the name of the function.

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

What is function declaration?

A

Function declaration is a way to create a function.

Syntax:
function myFunction() {
alert(‘hello’);
}

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

What is function expression?

A

Function expression is a way to create a function.

Syntax:
let sayHi = function() {
alert( “Hello” );
};

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

What is the “return” statement?

A

A “return” statement contains the information in a functions or action that will be returned. The statement determines the outcome of a function or action.

This statement also indicates that this is the end of any code to be run inside a function or code block. Once a return statement is met, no code after in that block will be run.

17
Q

What are callback functions?

A

Callback functions are functions that are passed and expected to be called back later if necessary. This concept can be duplicated using function expressions or anonymous functions (which they also tend to have better flow than callback functions.)

18
Q

What are JavaScript Call Stacks?

A

javaScript Call Stacks is a mechanism to keep track of the function calls and how the JavaScript engine executed what code when.