Mutability And Reference VS Privative Types in JavaScript
Mutability And Reference VS Privative Types in JavaScript
Mutability && Primitive && Reference Examples
var myStr = "Bob";
myStr[0] = "J";var myStr = "Bob";
myStr = "Job";Objects are passed by reference, are mutable, and can be modified by our functions:
function rotateLeft(arr, num) {
for (let i = 0; i < num; i++) {
let el = arr.pop();
arr.unshift(el);
}
}
let myArr = [1, 2, 3, 4, 5, ];
rotateLeft(myArr, 2);
console.log(myArr);Dereferencing
Arrays
Objects
Primitive Data Types in Depth

Check Out My New Blog:
Last updated
