Skip to interview prep
Apexed

13. What is the difference between passing by value and by reference?

EasyProgramming fundamentals

Technical
Show model answer

Passing by value gives the function a copy, so changes do not affect the caller. Passing by reference gives access to the caller's variable itself.

Languages like Java, JavaScript and Python pass object references by value: the function can mutate the shared object, but reassigning the parameter does not change the caller's variable.

What is the difference between passing by value and by reference — Software engineering interview question — Apexed