+ 2

What are Immutable Objects and Mutable Objects

Immutable and Mutable

2nd Mar 2022, 8:20 AM
DAVID MPHANDE
DAVID MPHANDE - avatar
1 Answer
+ 5
Immutable objects can't be changed after it is created. It means you can't modify their values/elements For example strings in JS var str = "David" // declaration str[0] = 'A' //. Wrong because strings are immutable /†******************************/ Mutable objects are those that can be change later For example arrays var arr = [ 1, 2, 3] arr[0] = 1000 //. valid
2nd Mar 2022, 8:39 AM
NonStop CODING
NonStop CODING - avatar