Here is an example of w shallow copy and this will work in this scenario
const players = [1, 2, 3, 4];
check();
function check()
{
// CAUTION : This is only a shallow copy and will work with value types
// If you use on ref types, it will be pointing to the same objects.
let innerArr = players.slice();
innerArr.pop();
console.log(players);
console.log(innerArr);
return innerArr;
}
solved Is there any option to make it work? global+local varriable [closed]