Mutability
Mutability && Primitive && Reference Examples
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);function rotateString(str, num) {
return str.slice(num) + str.slice(0, num);
}
let str = "foobar";
let ret = rotateString(str, 3);
console.log(str);
console.log(ret);Dereferencing
Arrays
Objects
Last updated