Parameter Names

Hi,

Thought I would go back to basics and learn the foundation of this language.

Doing ok, but I need clarification.

Why do these different functions, still behave the same?

function doSomething(name) { 
     alert('Hello ' + name); 
}
		
     var name = 'Nick';
     doSomething(name);
function doSomething(firstName) { 
     alert('Hello ' + firstName);
}
		
     var name = 'Nick';
     doSomething(name);

What you pass in as a parameter has a local scope: it is a local variable. In your example above, the functions are, in essence (except nominally), identical.

What you may be getting confused with is the fact that you did:
doSomething(name);
While the first example may seem to make more sense, the second example works because you passed in the variable ‘name’ into the function’s local variable (parameter). The ‘name’ variable that you passed it automatically becomes ‘firstName’, local to the function.

Hopefully that was clear enough.

yeah, just wanted clarification.