I study JS here and ask a question about primitive values ββwhen passing as arguments. Let's say I have a simple function:
var first = 5;
var second = 6;
function func(){
first+=second;
}
func();
alert(first);
Thus, in this case, the value of the first is 11 .. But if I try it, passing it first as an argument to the function, first 5 will remain ..
var first = 5;
var second = 6;
function func(first){
first+=second;
}
func(first);
alert(first);
I wonder if anyone can explain this to me.
source
share