Functions Flashcards

1
Q

ES6 distinguishes between 2 types of functions. What are they?

A

Callable (cannot be called with new) Constructable (can be called with new, return an object)

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

Functions created via the arrow function syntax or via a method definition / object literals are not ….

A

Constructable

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

When I create a function, how do I make it NOT a constructor?

A

To create a function that is not constructable, you can use an arrow function.

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

What is the default return value of a function?

A

Undefined

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

When defining a function, the identifiers that are placed within the brackets are called …

A

Parameters

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

When identifiers or variables are passed into a function for execution, they are known as …

A

Arguments

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

What are 4 unique properties of an arrow function?

A
  1. It does not have its own this
  2. It does not have its own arguments
  3. It does not its own super
  4. It does not have its own new.target
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Can arrow functions be used as constructors?

A

No. They are callable, not constructable. They do not pass on a this context.

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

If arrow functions do not have their own this value, how does this take its value within the function?

A

The this value of the enclosing lexical scope is used, e.g. arrow functions follow the normal variable lookup rules.

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

What 4 steps happen automatically when invoking a function as a constructor?

A
  1. ) A new object is created (O)
  2. ) the new object is [[Prototype]]-linked (P)
  3. ) the new object is set as the ThisBinding for the function’s execution context (E)
  4. ) the new object is returned* (N)

O.P.E.N.

* Unless the function overrides this with its own explicit return

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