JavaScript-Quiz: this, call, apply & bind

This JavaScript quiz covers this, one of the most asked interview topics. You will work out what this is in methods, detached functions and arrow functions, and set it yourself with call, apply and bind.

Schwer 10 Fragen ~8 Minuten Bestanden ab 80% Node.js 22

Modus wählen

Du spielst als Gast: Melde dich an, damit XP und Serie gespeichert werden.

Beispielfrage

Frage 1 von 10

What does this print?

const user = {
  name: "Ann",
  greet() {
    return `Hi, ${this.name}`;
  },
};
console.log(user.greet());
Lösung zeigen

A. Hi, Ann When a function is called as user.greet(), this is the object before the dot. So this.name is "Ann".

Darum geht es in diesem Quiz

  • this is decided by how a function is called, not where it is written
  • Losing this when a method is passed around
  • Arrow functions take this from the surrounding code
  • call and apply run a function with a chosen this
  • bind returns a new function with this fixed for good

Häufige Fragen

Brauche ich ein Konto?

Nein. Jeder kann spielen. Mit Anmeldung werden XP, Serie, Abzeichen und Verlauf gespeichert.

Kann ich es wiederholen?

Ja. Dein Bestwert bleibt erhalten, und Fragen und Antworten werden jedes Mal neu gemischt.