Quizzes`this` — Four Rules and an Arrow Function — Concept Check
intermediate
javascript

`this` — Four Rules and an Arrow Function — Concept Check

Questions on `this` — Four Rules and an Arrow Function. In JavaScript `this` is decided by how a function is called, not where it is defined — except in arrow functions, which have no `this` of their own and inherit it from the surrounding scope.

7 minutes 7 questions Pass at 70%
Time Limit
7 minutes - timer starts when you begin
Change Answers Freely
Revisit and change any answer before submitting
Full Review After Submit
Correct answers and explanations shown for every question
Auto-submit on timeout
Quiz submits automatically when time runs out

Questions in this quiz

7 questions on `this` — Four Rules and an Arrow Function — Concept Check. Work through them here, then start the quiz to answer them and see your score.

  1. 1.A developer extracts a method from an object and calls it separately. What is the likely result?

    • AThe method will throw an error due to missing `this`.
    • BThe method will automatically bind to the global object.
    • CThe method retains its `this` context and works as intended.
    • DThe method loses its `this` context and may not work as intended.
  2. 2.What happens when an arrow function is used as a method in an object?

    • AIt automatically binds `this` to the global object.
    • BIt inherits `this` from the surrounding scope, not the object.
    • CIt throws an error due to missing `this`.
    • DIt binds `this` to the object it is defined in.
  3. 3.A function is called with `call()` method on an object. What does this imply?

    • A`this` is explicitly set to the object passed to `call()`.
    • B`this` defaults to the global object.
    • C`this` is bound to the function itself.
    • D`this` is set to `undefined`.
  4. 4.A method is passed as a callback to `forEach`. What common issue might arise?

    • AThe method retains its original `this` context.
    • BThe method loses its `this` context, causing a TypeError.
    • CThe method executes with `this` bound to each array element.
    • DThe method binds `this` to the global object.
  5. 5.How does `this` behave in a regular function compared to an arrow function?

    • ABoth bind `this` at call time.
    • BBoth inherit `this` from the surrounding scope.
    • CRegular functions bind `this` at call time; arrow functions inherit `this`.
    • DRegular functions inherit `this`; arrow functions bind at call time.
  6. 6.Why might a developer use `bind()` on a method?

    • ATo ensure `this` is fixed to a specific object.
    • BTo throw an error if `this` is undefined.
    • CTo allow `this` to change dynamically.
    • DTo bind `this` to the global object.
  7. 7.In strict mode, what is the default value of `this` in a standalone function?

    • A`undefined`
    • BThe function itself
    • CThe global object
    • DAn empty object