Квиз по JavaScript: Optional Chaining & ??

This JavaScript quiz covers optional chaining (?.) and the nullish coalescing operator (??). You will predict what they return for missing values, compare ?? with ||, and choose the safe way to read nested data.

Лёгкий 10 вопроса ~5 минуты Проходной балл: 80% Node.js 22

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

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

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

Вопрос 1 из 10

What does this print?

const user = { profile: null };
console.log(user.profile?.name);
Показать ответ

C. undefined ?. checks the value on its left. user.profile is null, so the expression stops and returns undefined instead of throwing. Note it returns undefined, not null.

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

  • ?. on properties, ?.[] on indexes and ?.() on calls
  • How ?. stops the rest of the expression
  • ?? vs || with 0 and ""
  • The ??= assignment
  • Which values count as nullish

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

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

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

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

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