Tag view

#copying

Cross-subject tag search for related interview cards.

Clear

Results update as you type. Press / to jump straight into search.

Tagged with copying

3 cards

Python Medium Theory

Nested lists and list copy behavior

Nested lists make shallow copies especially important because the outer list may copy while inner lists still alias the same objects.

  • Nested structures magnify aliasing bugs
  • list() or slicing makes a shallow copy
  • deepcopy is for fully independent nested state

Nested lists and list copy behavior

Python Medium Theory

Shallow copy vs deep copy

A shallow copy copies the outer container; a deep copy recursively copies nested objects too.

  • Shallow shares nested refs
  • Deep duplicates nested refs
  • copy and deepcopy from copy module

Shallow copy vs deep copy

JavaScript Medium Theory

Object.keys, Object.values, Object.entries, Object.assign, spread with objects, shallow copy vs deep copy, Object.freeze, and Object.seal

Object helpers are useful for inspection and copying, but most built-in copy patterns are still shallow.

  • `Object.assign` and spread are shallow
  • `freeze` and `seal` change mutability rules
  • Entries are useful for iteration

Object.keys, Object.values, Object.entries, Object.assign, spread with objects, shallow copy vs deep copy, Object.freeze, and Object.seal