I know that String and Number objects are immutable but are all built-in objects immutable as well? If it's not true, can you give me an example of a built-in object that is mutable?
2 Answers
Arrays are mutable. Here are a list of mutable methods for arrays.
push - Elements are added on to the end of the array
pop - Elements are removed from the end of the array
shift - Elements are removed from the beginning of the array
unshift - Elements are added to the beginning of the array
splice - Adds/removes elements to an array
None of these methods create a new array, but modify the existing array.
1 Comment
GniruT
Thanks for the detailed answer :)
Array,Object,Number,Stringand their respective prototypes.