functions Flashcards

1
Q

what type of statement is this

var awesomeFunction = function(coolThings) { // .. return amazingStuff; };

A

anonymous function expression

no identifier betwen function and (). gets an inferred name from assignment.

This function is an expression that is assigned to the variable awesomeFunction. Different from the function declaration form, a function expression is not associated with its identifier until that statement during runtime.

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

what type of statement is this

function awesomeFunction(coolThings) {
 // .. return amazingStuff;
}
A

function declaration

This is called a function declaration because it appears as a statement by itself, not as an expression in another statement. The association between the identifier awesomeFunction and the function value happens during the compile phase of the code, before that code is executed.

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

what type of statement is this

var awesomeFunction = function someName(coolThings) {
// .. return amazingStuff; };

awesomeFunction.name;

A

named function expression

// “someName”

someName is directly associated with the function expression at compile time

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

what type of statement is this

*two() { .. }

A

generator function declaration function

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

what type of statement is this

async function three() { .. }

A

async function declaration

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

what type of statement is this

async function *four() { .. }

A

async generator function declaration

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

what type of statement is this

export function five() { .. }

A

named function export declaration (ES6 modules)

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

what type of statement is this

(function(){ .. })();

A

immediately invoked function expresion

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

what type of statement is this

(async function(){ .. })();

A

async immediately invoked function expresion

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

what type of statement is this

(async function myname(){ .. })();

A

named async immediately invoked function expresion

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

what type of statement is this

(function myname(){ .. })();

A

named immediately invoked function expresion

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

what type of statement is this

const f = () => 42;

A

arrow function

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

what type of statement is this

const f = async () => 42;

A

async arrow function

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

what type of statement is this

const obj = {
 oldSchool: function() { .. }
}
A

(anonymous) function expression property

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

what type of statement is this

const obj = {
 boringMethod() { .. },
}
A

object method

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