Javascript 'this' keyword question

So I created a linked list object in js…I won’t explain i’ll just give an example with arrays

arr =[0, 1]    
console.log(arr); //[0, 1] 
console.log(arr)  //[0]    

But when I do myLinkedListRef (with say List of //2–>3–>6)

console.log(myLinkedListRef)//3 ->6    
console.log(myLinkedListRef) //3->6    

They are both the same!!!

Point i s that the remove method in linked list removes the value before the console log message is displayed the old value. Is there no way around this?

I was hoping the first message would log original list then the next would log the original list without first element but they are both logging list without first element

I cleaned up your code.
You need to use triple backticks to post code to the forum.
See this post for details.

No, it doesn’t. There’s something else going on here, but it’s not possible to know what from the little bit of code you’ve written here. You can embed runnable code examples in the forum now, so put up your working example that demonstrates spooky linked-list action and we’ll figure out what’s actually happening.

Also, what does your question have to do with the this keyword?

1 Like

Stack overflow helped. The console.log() was messing things up.