JavaScript Quiz: Objects & Copying

Objects and arrays in JavaScript are passed around by reference, which leads to some of the most common bugs. This quiz tests references, const, spread copies, structuredClone(), the JSON trick and Object.freeze().

मीडियम 10 सवाल ~6 मिनट पास होने के लिए 80% Node.js 22

मोड चुनें

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

सैंपल सवाल

सवाल 1 / 10

What does this print?

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

B. 2 const b = a copies the reference, not the object. Both names point to the same object, so changing b.x changes what a.x shows.

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

  • Variables that point to the same object
  • Shallow copies with spread and Object.assign()
  • Deep copies with structuredClone() and the JSON round trip
  • What const and Object.freeze() really protect
  • Comparing objects with ===

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

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

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

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

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