Functions Flashcards
What is the invocation context of a function ?
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.
Javascript functions are closures. What does it mean ?
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.
What are the different ways to create functions in javascript ?
- 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.
What does the following mean: Function declarations are hoisted ?
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.
Functions are objects.
True or False ?
True