I was creating a code where I need to use some variables from a global scope, when I made my local = global, I've noticed the changes I've made in the local scope were being modified into the global scope.
This is an example of what I am talking about
global = [];
load_global();
use_global();
function load_global() {
  for (i = 0; i < 10; i++) {
    global.push(i);
  }
}
function use_global() {
  local = [];
  local = global;
  for (i = 0; i < 5; i++) {
    global.push("x");
  }
  console.log(local);
}
Is there a way to use the values of a global array, but without changing it?
 
     
     
     
     
    