a - what is mutability mutability refers to whether an object's state can be changed after it's created mutable objects can be changed, and immutable ones can't. Primitives types numbers, strings, booleans, etc., are immutable. if I assign a variable to a number, and then change it, that's actually creating a new value. if I have let x = 5; then x = 10; that's not modifying the original 5, but creating a new number. But objects, like arrays, objects, and functions, are mutable. if I have an object and change one of its properties, that's modifying the original object. let obj = {a: 1}; then obj.a = 2; that changes the object. In JavaScript, the default for objects is mutability. But of course you can use Object.freeze or other libraries to help with immutability
b - mutability examples JavaScript has six primitive types: number, string, boolean, null, undefined, and symbol. These are immutable by nature, meaning their values cannot be changed after creation. Example 1 → it creates a new number value, not a mutation of the original. JavaScript objects (including arrays, functions, and objects) are mutable by default. This means their properties can be changed after creation. Example 2 → Modifies the original object. Object.freeze() freezes an object, making its properties non-writable, non-configurable, and non-enumerable. Example 3 → No effect; throws no error, but the change is ignored. const offers variable immutability and prevents reassignment, but not object mutation.