Pass by Value Vs Pass by Reference

Pass by value:

Code snippet for JavaScript:

The main aspect of pass by value is :”You cannot modify the values you pass into the function”. But you may wonder how ‘t’ got changed?
Actually if you examine carefully,’t’ never changed.The object which ‘t’ was referencing got changed.

Pass by Reference:

If you can modify the values passed onto a function,then it is pass by reference.

Pass by Reference in C:

Pass by Reference in C++:

Suffering from Knowledge Quest

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store