Posts by joaoricardotg • 53 points
1 post
-
4
votes2
answers151
viewsQ: Why does changing a variable in a function not reflect in the passed variable itself?
let a = 2; let change = (val) => { val = 3; } change(a); console.log(a); I hoped the value of a was 3, but actually it is 2. Why?…