Function Arguments pass by value vs pass by reference
JavaScript
function passObject(obj){
obj.name = "Hey";
}
function passByValue(x){
x = 9;
}
var x = 10;
console.log("Value of x before function:- ", x);
passByValue(x);
console.log("Value of x after function:- ", x);
var someObj = {
"name": "Bye"
};
console.log("Value of someObj before function:- ", JSON.stringify(someObj));
passObject(someObj);
console.log("Value of someObj after function:- ", JSON.stringify(someObj));