Functions JS fill in the blank Flashcards

(93 cards)

1
Q

A function in JavaScript is a block of code that is defined once and can be executed many times when it is ____ or ____.

A

invoked, called

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

Functions in JavaScript can be categorized into several types such as named, anonymous, and ____ functions, as well as ____ functions.

A

recursive, IIFEs

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

Closures are important in JavaScript because they establish context for code execution and are key to ____ programming and ____ functions.

A

asynchronous, generator

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

In JavaScript, functions can be treated as values and can be passed to other functions or ____ from other functions, demonstrating their ____ nature.

A

returned, first-class

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

To change the value of the ‘this’ keyword in JavaScript, you can use methods like apply, call, and ____. These methods are essential for ____ functions.

A

bind, higher order

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

When defining a function in JavaScript, it can be done as a declaration or an ____, and it is invoked using ____.

A

expression, parentheses

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

Higher order functions in JavaScript can receive functions as arguments or ____ functions, showcasing their flexibility and ____ capabilities.

A

return, functional

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

Generator functions and iterators in JavaScript are used for ____ over values, making them essential for ____ programming.

A

iterating, asynchronous

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

The main types of functions in JavaScript include named, anonymous, recursive, inner, outer, and ____. Each serves a different ____ in programming.

A

IIFEs, purpose

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

In JavaScript, a function is defined using the ____ keyword followed by the ____ name.

A

function, function

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

The executable code block of a function is contained within ____ braces and may return a value using the ____ keyword.

A

curly, return

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

To invoke a function in JavaScript, you must use ____ after the function name and can pass values by including them in the ____ .

A

parentheses, parentheses

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

Functions in JavaScript can be treated as ____ because they can be passed around like ____ values.

A

values, primitive

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

When defining a function, the function name is followed by parentheses which can include ____ to be passed into the function.

A

arguments

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

The ‘sum’ function takes two parameters, ____ and ____, and returns their ____ .

A

num1, num2, sum

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

To change the context of a function, you can use methods like ____, ____, or ____ .

A

call, apply, bind

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

In JavaScript, the most common way to define a function is through a function ____ .

A

declaration

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

The return value of a function can be captured in a variable by assigning it to a ____ .

A

let, const, var

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

The output of the ‘sum’ function when called with 20 and 30 is ____ .

A

50

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

A function can be ____ to a variable similar to a ____ value.

A

assigned, primitive

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

A function can be stored in an ____ similar to a ____ value.

A

array, primitive

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

A function can be passed to another function as an ____ and may also be ____ from a function.

A

argument, returned

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

In JavaScript, functions are treated like any other ____ because they are first class ____.

A

value, functions

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

A named function is created by providing a name after the function ____ keyword.

A

declaration, function

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
25
An anonymous function is defined inside a larger ____ and may not have a ____ name.
expression, specific
26
A recursive function calls itself as a part of the executing ____ code.
block, function
27
In the example, the function 'sum' is invoked by getting the ____ element in the array.
third
28
The output of the function 'sum' when called with 20 and 30 is ____ .
50
29
Different types of functions in JavaScript depend on how they are ____ .
used, defined
30
In JavaScript, an ____ function is defined within the code block of another function, while an ____ function is the outer function.
inner, outer
31
A function that is invoked at the same time it is defined is called an ____ (pronounced as 'iffy'), while a function that is assigned to a variable is known as a ____ function.
IIFE, function expression
32
The 'fib' function in the example is an example of a ____ function, while the function defined as 'num3' is an ____ function.
outer, anonymous
33
In the provided example, the greeting is displayed after a delay of ____ milliseconds, and it uses a ____ function to update the HTML content.
1000, setTimeout
34
A function expression is similar to a function declaration, but it is used to define a function as part of an ____ rather than a standalone statement.
expression
35
The 'greeting' function takes a parameter named ____, and it uses a template literal to create a greeting message that includes this ____.
name, name
36
In JavaScript, functions can be ____ which means one function can be defined inside another function, allowing for more complex behavior.
nested
37
The output of the 'fib' function when called with arguments 0 and 1 is an array containing the values ____.
0, 1, 1
38
In recursion, a function calls itself to solve a problem, and it requires a specific ____ to avoid infinite loops.
exit condition, base case
39
The Fibonacci sequence starts with 0 and 1, and each number is the sum of the previous ____ numbers.
two, numbers
40
An infinite recursion occurs when a recursive function lacks an ____ condition, leading to an infinite loop.
exit, base
41
Arrow functions provide a more ____ syntax compared to traditional function expressions in JavaScript.
compact, concise
42
In the Fibonacci function, if the sequence length is greater than or equal to the specified length, it will ____ the sequence.
return, output
43
The error thrown by JavaScript when maximum call stack size is exceeded is called a ____ error.
RangeError, stack overflow
44
To compute the Fibonacci sequence, the function uses the last two numbers in the sequence to calculate the ____ number.
next, subsequent
45
The function 'multiply' demonstrates an infinite recursion by calling itself without a proper ____ condition.
exit, termination
46
In the example of infinite recursion, the function 'multiply' uses the method ____ to remove the last element from the array.
pop, shift
47
In JavaScript, when a function has a single parameter, the parentheses can be ____ and the return statement can be ____ if the body has only one statement.
removed, implied
48
The arrow function version of a function can omit the ____ if it has a single statement, and the ____ keyword can also be omitted.
braces, return
49
In traditional functions, the this keyword is set to the object that ____ the function, while in arrow functions, it is determined by the ____ of the function call.
invoked, context
50
When defining an arrow function without parameters, you must use an empty set of ____ to indicate that there are no parameters.
parentheses
51
The arrow function version of the greeting function can be written as name => console.log(`Good Morning ____ !`);, where ____ is the parameter name.
{name}, name
52
In the arrow function version of the sum function, the syntax is num1, num2 => num1 ____ num2; where the operator is ____ .
+ , +
53
In the random function example, if the generated number is greater than 5, the return value is ____; otherwise, it returns the ____ .
0, num
54
The arrow function version of the random function uses an implicit return when there is a single ____ statement.
expression
55
In JavaScript, the this keyword in arrow functions does not default to the ____ object, unlike traditional functions.
global
56
In JavaScript, if 'this' is not set by the call, it defaults to the _____ object and can refer to _____ in a method.
global, the object itself
57
When calling 'sayHeight' from the person object, 'this' refers to the _____, while calling 'sayWeight' results in 'this' being the _____ object.
person, global
58
A higher-order function can either receive a function as an _____ or return a function as a _____ value.
argument, return
59
The 'map' method of the Array object is an example of a higher-order function because it accepts a _____ as an argument and returns a new _____.
function, array
60
In the example of 'createMultiplyFunction', it returns a function that multiplies its input by a given _____, demonstrating the concept of _____ functions.
number, higher-order
61
A function passed into another function is known as a _____ function, which is essential for _____ coding in JavaScript.
callback, asynchronous
62
In the event listener example, the 'showDate' function is executed when the button is clicked, allowing the program to continue running without _____ at that point.
stopping
63
When 'showDate' is called, it logs the values of '_____ ' and '_____ ' to the console, demonstrating the use of event listeners.
intro, date
64
The output of 'multiplyBy10(5)' is _____, showing how a function can be returned and used later in JavaScript.
50
65
In the context of asynchronous functions, the 'addEventListener' method allows for _____ execution of code when an event occurs.
non-blocking
66
In JavaScript, synchronous code runs in a ____ manner, while asynchronous code operates ____ the normal sequence of execution.
synchronous, outside
67
Function declarations in JavaScript are ____ which means they can be invoked before they are ____ in the code.
hoisted, defined
68
Closure in JavaScript allows a function to access its ____ scope even after the function that created the parent scope has ____ execution.
parent, completed
69
An example of asynchronous code is when an event handler is set up for a button, but it is not executed until the button is ____ and ____ is triggered.
clicked, the event
70
When a function expression is invoked before it is defined, it results in a ____ error, while a function declaration does not.
ReferenceError
71
In the example of closure, the 'createScoreFunction' returns a function that adds to the ____ array and then prints the number of ____.
scores, values
72
JavaScript code runs to completion without stopping in a ____ manner, while asynchronous code allows for ____ operations.
synchronous, non-blocking
73
The main difference between function declarations and function expressions is that function declarations are ____ and can be invoked at any time.
hoisted
74
The apply() method invokes a function and passes in the arguments as a _____, while the call() method passes them as a _____.
array, comma separated list
75
In JavaScript, the bind() method returns a new function and assigns the object passed in to the keyword 'this', allowing for _____ and _____ of arguments.
binding, passing
76
When using the call() method, the first argument is the object to be assigned to 'this', and the second argument is the _____, which is passed as a _____.
function, comma separated list
77
In the context of the objGreet object, the morningGreet function uses the keyword 'this' to access the user's _____, while the eveningGreet function does the same for the _____ parameter.
firstName, punct
78
The createScoreFunction returns a function that can access the scores array through _____, allowing it to modify the _____ of scores.
closure, length
79
The output of addScore(70) shows that the total scores is now _____, while addScore(90) increases it to _____.
1, 2
80
In the example provided, objGreet.morningGreet.call(user1, '!') demonstrates the use of _____ to invoke a function with a specific context.
call
81
The bind() method is unique because it returns a new function that can be invoked later, allowing for the _____ of parameters to be set in advance.
binding
82
The generator function is defined with an asterisk (*) and is used to create a _____ that can yield multiple values over time.
generator
83
The eveningGreet function in objGreet uses the keyword 'this' to refer to the _____ of the user object passed in.
firstName
84
A generator function is defined with an asterisk (*) and can be used with the ____ method to iterate over ____ values.
next(), values
85
The yield keyword is used in a generator function to ____ the function and return the ____ in the current iteration.
pause, value
86
In the fibonacci sequence generator, the first two numbers are ____ and ____ before generating the next numbers.
0, 1
87
The next() method returns an object with properties 'value' and ____ which indicates if there are more values to return.
done
88
When there are no more values left to return, the 'done' property becomes ____ and the value returned is ____ .
true, undefined
89
An iterator is a special object that implements a ____ sequence for a collection of ____ .
one-at-a-time, items
90
In the progressive factorial example, each time next() is used, a new ____ and its ____ are displayed.
number, factorial
91
The fibonacci sequence generator produces a sequence of ____ numbers, with each new number being added ____ at a time.
100, one
92
The output of the fibonacci sequence generator is an array that contains the ____ of the sequence generated so far.
values
93
The rhymeGenerator function yields several lines including 'One, two, three, four, five,' and '____ I caught a fish alive.'
Once