The "this" keyword Flashcards
Understanding what the 'this' keyword refers to in JS
The ‘this’ keyword evaluates to the value of the … of the current execution context
The ‘this’ keyword evaluates to the value of the ThisBinding of the current execution context
The … site determines the …Binding
The callsite determines the ThisBinding
This is the … that owns the method in a method invocation
This is the object that owns the method in a method invocation
When invoking a method on an object, this becomes …
When invoking a method on an object, this becomes the object itself
In non-strict mode, a function’s internal ThisBinding defaults to …
In non-strict mode, a function’s internal ThisBinding defaults to the global object (the window object in a browser)
In regards to the ThisBinding, there is an important distinction between … invocation & … invocation
In regards to the ThisBinding, there is an important distinction between function invocation & method invocation
In regards to prototypal inheritance, the ThisBinding is still the context of the …, even when the prototype chain is queried
In regards to prototypal inheritance, the ThisBinding is still the context of the invocation, even when the prototype chain is queried
What is this automatically set to in a constructor function?
This is set to the newly created object
If we run a function in the global execution context, and console.log the this value inside the function, what will we see when we call the function?
We will see ‘window’ in a browser in non-strict mode.
We will see undefined in strict-mode.
In ES6 classes, methods called on a class use the … as the ThisBinding
In ES6 classes, methods called on a class use the object itself as the ThisBinding
Do arrow functions have their own ThisBinding?
No, arrow functions defer to the ThisBinding of their surrounding lexical context
What is the difference between call & apply?
Both call and apply take an object as their first argument, which sets the this value of a function. However, call takes a list of comma separated arguments as optional inputs, while apply takes an array of arguments as the second optional argument.
Name 3 methods that can explicitly change the this value of a function.
.call()
.apply()
.bind()
Every single JavaScript program is executed within an …
Execution Context
Every execution context has a …
ThisBinding