ควิซ 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 และ streak

ตัวอย่างคำถาม

ข้อ 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, streak, เหรียญตรา และประวัติ

ทำซ้ำได้ไหม?

ได้ ระบบเก็บคะแนนที่ดีที่สุดไว้ และสลับคำถามกับตัวเลือกใหม่ทุกครั้ง