> primitive values and reference values.
You maybe know that but do you know what are the difference between those 2 types ? How they stores in memory ?
> if your answer is "no", not to worry, we are gonna discuss all this in details. Just keep reading this blog 😊
Now let's see how Primitive values differs from Reference values :
If you come from different languages ( e.g : C/C#, Java ) you probably know the concept of 'PASS BY VALUE' & 'PASS BY REFERENCE'.
In simple terms...
"Passing by value"_ means that you pass the actual value of the variable into the function. So, in your example, it would pass the value 9._
"Passing by reference" means that you pass the variable itself into the function (not just the value). So, in your example, it would pass an integer object with the value of 9.
Primitives : We store the actual value.
Reference : Here variable store the address where the data in heap memory is located. This doesn't store the actual value like primitives, instead a pointer or a reference to data.
PRIMITIVES VALUES :
- Value types are immutable.
- value types are compared by value.
- value types are copied by value.
REFERANCE VALUES :
- reference types are mutable.
- reference values are copied by address to memory or reference.
If you find this blog helpful make sure to give it 💛, also can follow me on Twitter for more helpful resources and tips.