Quiz de 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.

Fácil 10 perguntas ~5 minutos Aprovação com 80% Node.js 22

Escolha um modo

Jogando como visitante: entre para guardar seu XP e sua sequência.

Pergunta de exemplo

Pergunta 1 de 10

What does this print?

const user = { profile: null };
console.log(user.profile?.name);
Mostrar a resposta

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.

O que este quiz cobre

  • ?. 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

Perguntas frequentes

Preciso de uma conta?

Não. Qualquer pessoa pode jogar. Entre para guardar seu XP, sequência, badges e histórico.

Posso refazer?

Pode. Sua melhor nota fica salva, e as perguntas e respostas são embaralhadas a cada vez.