ควิซ JavaScript: Scope & Hoisting

This JavaScript quiz covers scope and hoisting, including the temporal dead zone (TDZ). You will predict how var, let, const and functions behave before their line runs, and how inner scopes shadow outer ones.

ปานกลาง 10 ข้อ ~6 นาที ผ่านที่ 80% Node.js 22

เลือกโหมด

กำลังเล่นแบบผู้เยี่ยมชม: เข้าสู่ระบบเพื่อเก็บ XP และ streak

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

ข้อ 1 จาก 10

What does this print?

console.log(a);
var a = 5;
ดูเฉลย

B. undefined var a is hoisted to the top of its scope and starts as undefined; only the assignment a = 5 stays on its line. So the log runs before the value is set.

ควิซนี้มีเนื้อหาอะไรบ้าง

  • Hoisting of var: declared early, undefined until assigned
  • The temporal dead zone for let and const
  • Function declarations vs function expressions
  • Block scope, function scope and shadowing
  • Why typeof does not help inside the TDZ

คำถามที่พบบ่อย

ต้องมีบัญชีไหม?

ไม่ต้อง ใครก็เล่นได้ เข้าสู่ระบบเพื่อเก็บ XP, streak, เหรียญตรา และประวัติ

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

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