Junior — Middle
Can you name data types that can be modified after creation?
sobes.tech AI
Answer from AI
Data types that can be modified after creation are called mutable. They include:
- In object-oriented programming languages — objects, arrays, lists, dictionaries (e.g., in Python, JavaScript).
- In JavaScript: objects, arrays, functions.
- In Python: lists (
list), sets (set), dictionaries (dict).
Example in JavaScript:
const arr = [1, 2, 3];
arr.push(4); // array has changed
Example in Python:
my_list = [1, 2, 3]
my_list.append(4) # list has changed
Unlike them, immutable types — strings, numbers, tuples (in Python), primitives in JavaScript — cannot be changed after creation, only a new object with modified data can be created.