0
0
Javascriptprogramming~5 mins

What this keyword represents in Javascript - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What does the this keyword represent in JavaScript?

The this keyword refers to the object that is currently executing the code. It changes depending on how a function is called.

Click to reveal answer
intermediate
In a regular function, what does this refer to in strict mode?

In strict mode, this inside a regular function is undefined. Without strict mode, it refers to the global object (like window in browsers).

Click to reveal answer
intermediate
How does this behave inside an arrow function?

Arrow functions do not have their own this. They inherit this from the surrounding (lexical) scope.

Click to reveal answer
beginner
What does this refer to when used inside an object method?

Inside an object method, this refers to the object that owns the method.

Click to reveal answer
intermediate
How can you explicitly set the value of this when calling a function?

You can use call(), apply(), or bind() methods to explicitly set this when calling a function.

Click to reveal answer
What does this refer to inside a regular function called in the global scope (non-strict mode)?
AThe function itself
BThe object that called the function
CUndefined
DThe global object (e.g., window in browsers)
Inside an arrow function, this is:
ABound to the arrow function itself
BInherited from the surrounding scope
CAlways the global object
DUndefined
Which method can be used to permanently set this for a function?
Abind()
Bapply()
Ccall()
DsetThis()
In an object method, this refers to:
AUndefined
BThe global object
CThe object owning the method
DThe method itself
What is the value of this inside a function in strict mode if called without an object?
AUndefined
BThe function itself
CThe last object used
DThe global object
Explain how the value of this changes depending on how a function is called in JavaScript.
Think about different ways to call functions and how this behaves.
You got /4 concepts.
    Describe the difference between this in regular functions and arrow functions.
    Focus on how this is determined inside each function type.
    You got /3 concepts.