Call By value and Call by reference
call by value or passed by value
let a = 10; let b = a;so in this example, variable b is storing the value of a. if we change the variable b, then only variable b will affects not variable a, because both are in different memory location. this is mean by passed by value.
call by reference or passed by reference
let a = { name : 'shreyesh', age : 20 } let b = ahere b is storing the address or reference of variable a. and if we modify b like b.name = 'vaibhav'; so the original a will also affect becouse the momory location is same for a and b. this term known as passed by reference
Post a Comment