I made this object in javascript.
let list = {
value: 1,
next: {
value: 2,
next: {
value: 3,
next: null,
},
},
};
And also a function to traverse it...
function traverse(list_) {
while (list_) {
console.log(list_.value);
list_ = list_.next; // (*)
}
}
traverse(list);
Inside of the function I am changing the reference to the passed argument at (*), so at the end of the function I was expecting the value of list object to be null as well, but when I log the value of list after the function, it still shows the same object...
Does this mean that list was passed by value, and not by reference?