JavaScript is only pass-by-value, unlike C++ which also has pass-by-ref

preview_player
Показать описание
JavaScript does not have pass-by-reference and here is a side by side comparison with C++ which has pass-by-reference
Рекомендации по теме
Комментарии
Автор

Namaste sir,
If it's a pass by value, it should pass a copy of original value right? Then
Modifying the copied value ( changing properties of copied value ), shouldn't affect the original value. but it does though!!!.

For me, It's neither pass-by-reference nor pass-by-value, it's just an another reference to the same value, defined with ( let ) and initialized inside the function definition.

Reference can modify the actual value passed
Reference can be re-initialized with different value.

Inspired a lot by your works.

vigneshwarrv