Квиз по JavaScript: Objects & Copying

Objects and arrays in JavaScript are passed around by reference, which leads to some of the most common bugs. This quiz tests references, const, spread copies, structuredClone(), the JSON trick and Object.freeze().

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

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

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

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

Вопрос 1 из 10

What does this print?

const a = { x: 1 };
const b = a;
b.x = 2;
console.log(a.x);
Показать ответ

B. 2 const b = a copies the reference, not the object. Both names point to the same object, so changing b.x changes what a.x shows.

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

  • Variables that point to the same object
  • Shallow copies with spread and Object.assign()
  • Deep copies with structuredClone() and the JSON round trip
  • What const and Object.freeze() really protect
  • Comparing objects with ===

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

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

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

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

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