Javascript beginner here. I am trying to understand the difference between the two examples below and why they present with different outcomes. Any help would be really appreciated! Thanks!
Example 1
var age = 30;
function changeAge(a) {
a = 20;
}
changeAge(age);
console.log(age); // ------ output = 30
Example 2
var age = 30;
function changeAge() {
age = 20;
}
changeAge();
console.log(age); // ------ output = 20