Assign the object to the variable and modify the variable. why hasn't the object been changed?

encountered a problem writing publication subscriptions.
I emptied the fns when I called crop.remove (), but there was data to print the fns. Fns.length = 0; this can be cleared. Doesn"t fns also point to this.list [key]?
there are printing results below

let crop = {
      list: {},
      on(key, fn) {
        if(!this.list[key]) {
          this.list[key] = [];
        }
        this.list[key].push(fn);
      },
      emit(key, ...payload) {
        let fns = this.list[key];
        if(!fns || fns.length === 0) return;
        fns.forEach(fn => {
          fn.apply(this, payload);
        })
      },
      remove(key, fn) {
        let fns = this.list[key];
        console.log(key);
        fns = [];
       
      }
    }

Mar.28,2021

there are
var a = [1];
var barium;
b = []
aura? The same sense of
fns = [] does not make this.list [key] []


fns = [] it just points the fns to the new []


let fns = this.list[key];
console.log(key);
fns = [];

fns points to this.list [key] , but fns = [] is equivalent to pointing fns to a new array.
is similar to,

let fns = objA; // fnsobjA
fns = objB; // fnsobjBfnsobjBobjA

fns.length = 0; it can be emptied because your fns = this.list [key];
fns = []; this does not empty this.list [key] you can understand that fns = 1; you are re-assigning the variable fns to this.list [key]; it has nothing to do with it.

Menu