# JavaScript Interview Questions: Mutability vs. Immutability

Today I want to share some interview questions that were asked to me related to immutable and mutability concepts in javascript. If you're prepping for a JavaScript interview, this might be helpful! 💡

### 1 - Question: What is mutable and immutable in JavaScript?

👉 Answer: Mutable: Objects and arrays are mutable, meaning you can modify their contents after creation—add, delete, or change properties. Immutable: Primitive data types like strings, numbers, booleans, null, undefined, and symbols are immutable. Once created, their values cannot be changed.  

### 2 - Question: Does using const or let affect mutability?

👉 Answer: Using const or let doesn't affect the mutability of a variable's value. const prevents reassignment but allows changes within objects or arrays. let allows reassignment but doesn’t influence whether the value is mutable or immutable.  

### 3 - Question: If we add an element to an object or array defined with const, are we changing its value?

👉 Answer: When you add an element to an object or array defined with const, you’re not changing the variable’s reference but modifying its content. Since the reference remains the same, JavaScript allows this even with const.

Thank you for reading! I am very excited to publish my first blog on Hashnode! Please let me know your thoughts in the comments.
