Functions Flashcards

1
Q

What is the invocation context of a function ?

A

It is the value of the ‘this’ keyword.
Usually, when a function that is a property of an object is invoked on (or through) this object, that object is the invocation context or the ‘this’ value for the function.

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

Javascript functions are closures. What does it mean ?

A

It mean that javascript functions can be nested within other functions, and they have access to any variables that are in scope where there are defined.

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

What are the different ways to create functions in javascript ?

A
  • Using the function keyword either as a declaration or as an expression
  • Using the shorthand syntax (arrow functions)
  • In object litterals and class definitions, using the shorthand syntax for declaring methods. As well as getters and setters.
  • Using the Function constructor
  • Using specialized kind of functions as : generators (function*) and async functions.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What does the following mean: Function declarations are hoisted ?

A

Function declarations are hoisted to the top of the enclosing script, function or block so that functions defined in this way may be invoked from code that appear before the definition.

It means that all of the function declared in a block of javascript code will be defined throughout that block, and they will be defined before the javascript interpreter begins to execute any of the code in that block.

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

Functions are objects.
True or False ?

A

True

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