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().

Mittel 10 Fragen ~6 Minuten Bestanden ab 80% Node.js 22

Modus wählen

Du spielst als Gast: Melde dich an, damit XP und Serie gespeichert werden.

Beispielfrage

Frage 1 von 10

What does this print?

const a = { x: 1 };
const b = a;
b.x = 2;
console.log(a.x);
Lösung zeigen

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.

Darum geht es in diesem Quiz

  • 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 ===

Häufige Fragen

Brauche ich ein Konto?

Nein. Jeder kann spielen. Mit Anmeldung werden XP, Serie, Abzeichen und Verlauf gespeichert.

Kann ich es wiederholen?

Ja. Dein Bestwert bleibt erhalten, und Fragen und Antworten werden jedes Mal neu gemischt.