Let’s say, I have a requirement of making an array immutable(no one can modify). Usually, when passing an array to a function as an input, it is passed by reference, not by value. So the function can change or alter its value instead of just using it.
A simple trick would be to freeze the array using Object.freeze
const fruits = Object.freeze(["Mango","Banana","Apple"]);
//now changing fruits array
//Will give you an error