DEV Community

Discussion on: A "Gotcha" of JavaScript's Pass-by-Reference

Collapse
 
bytebodger profile image
Adam Nathaniel Davis • Edited

I sincerely apologize for any misrepresentation. I understand that you were, overall, talking about pointers-vs-references. But your last example (which I took verbatim) ends with the conclusion:

It seems parameters are passed by value in JS. Are we agree now ? :)

But... no. We don't agree. For the reasons that I outlined in this follow-on article.

FWIW, I found your response to be logical and well thought out. And I wasn't trying to twist your words or troll you with this article. But it struck me that you gave a putative counter example that was conceptually identical to another putative counter example that was given in the exact same comment section.

This got me to thinking that there are many JS devs who look at examples like the ones you provided, and use those to conclude that JS does not pass by reference.

Some comments have been hidden by the post's author - find out more