JavaScript Quiz: let, const & var

This JavaScript quiz checks the three ways to declare a variable. You will predict output involving block scope, reassignment and redeclaration, and see why modern code uses const and let instead of var.

आसान 10 सवाल ~5 मिनट पास होने के लिए 80% Node.js 22

मोड चुनें

आप गेस्ट के तौर पर खेल रहे हैं: XP और streak सेव रखने के लिए साइन इन करें।

सैंपल सवाल

सवाल 1 / 10

What does this print?

let x = 1;
{
  let x = 2;
}
console.log(x);
जवाब दिखाएं

B. 1 The inner let x is a new variable that only lives inside the braces. Outside the block, x is still the outer one, which holds 1.

इस क्विज़ में क्या है

  • Block scope with let and const
  • Function scope with var
  • Why const stops reassignment but not changes to an object
  • Redeclaring a variable with var vs let
  • var vs let in a for loop

अक्सर पूछे जाने वाले सवाल

क्या अकाउंट ज़रूरी है?

नहीं। कोई भी खेल सकता है। XP, streak, badge और हिस्ट्री सेव रखने के लिए साइन इन करें।

क्या मैं इसे दोबारा दे सकता हूं?

हां। आपका बेस्ट स्कोर सेव रहता है, और हर बार सवाल और जवाब शफ़ल होते हैं।