Open In App

Pass by Reference in JavaScript ?

Last Updated : 22 Feb, 2024
Improve
Improve
Like Article
Like
Save
Share
Report

Contrary to common belief, JavaScript is not a pass-by-reference language but Instead, it is a pass-by-value for all its variable passing. In JavaScript, when an object is passed as an argument to a function a reference to the object is passed not a direct copy of the object itself. The modifications made to the object’s properties within the function persist outside the function, as the reference still points to the same underlying object. However, it is essential to understand that the reference itself is passed by value. If the reference is reassigned within the function, it does not affect the original reference outside the function. This behavior often leads to confusion, and developers must understand the distinction between pass-by-reference and the actual pass-by-value mechanism with references in JavaScript.


Like Article
Suggest improvement
Share your thoughts in the comments

Similar Reads