Квиз по JavaScript: 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.

Сложный 10 вопроса ~8 минуты Проходной балл: 80% Node.js 22

Выберите режим

Вы играете как гость: войдите, чтобы сохранить XP и серию.

Пример вопроса

Вопрос 1 из 10

What does this print?

const user = {
  name: "Ann",
  greet() {
    return `Hi, ${this.name}`;
  },
};
console.log(user.greet());
Показать ответ

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

Что проверяет этот квиз

  • 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

Частые вопросы

Нужен ли аккаунт?

Нет. Играть может любой. Войдите, чтобы сохранять XP, серию, значки и историю.

Можно пройти ещё раз?

Да. Лучший результат сохраняется, а вопросы и ответы каждый раз перемешиваются.