I'm new to javascript and thus the doubt. With primary data types like string this makes sense,
let a = "goat";
let b = a;
let a = "apple"
b; //"goat"
However with a custom object,
const item = this.head;
this.head = this.head.next;
return item.val;
Why does item still point to the same head, when head has moved and is pointing to something else?