JSFiddle - React, Tailwind, and code Playground

by Abdul Ahmad

JavaScript

let ar = [1, 2, 3, 4, 5];

function mutateArray(arr) {
	arr.forEach((item, index) => {
  	arr[index] += 5;
  });
}

function reassignArray(arr) {
	arr = [11, 12, 13, 14, 15];
}

console.log(ar);
mutateArray(ar);
console.log(ar);
reassignArray(ar);
console.log(ar);