Mutability
With primitive data type such as string or numbers, we can basically not mutate or change them. once a value has been assigned to a string or a number, we can not change that value to something else.
This is because primitive values are saved by values rather than reference
For objects, or complex datatypes, we can modify the value directly from the object, or in other words, mutate the objects.
-
Unlike primitive types, objects are saved by reference, therefore we are constantly pointing to a location in memory of where our object is saved thus are able to change it.
-
When you assign one object to another variable, what you are essentially doing is assigning the memory location to that variable,
- This will result in changing the object from one place and all the places referencing to the object changing.
-
When you compare objects with == operators, it compare the identity, it will produce true only if both objects are precisely the same value
Arrayology
Array provides many built-in methods that helps you interact with the array in question.
- You can add things at the end of the array (push)
- You can remove things (pop)
- count element and do much more.
Rest parameter
Functions takes in parameter, what if you are not quite sure of how many arguments your functions can take ? well you can bundle them all in one variable using the rest syntax
- This imply allows a function to receive any number of arguments(the stuffs you pass to your function when invoking it)