Well in javascript you can think that, scopes are defined my curly brackets: { And }, and inside a scope variables can be redefined, so look at:
function x(){
var name=3;
var name=4;
console.log(name); // output is: 4
}
x();
But this is just half true, actually what happens is that the interpreter goes over the code, and moves all var statements to the beginning, while they're assigned an undefined (and all arguments are defined and taken from stack), and then the code you wrote will run. So any var after the first is simply ignored. And the code you wrote is equal to:
function mytask(name,title){
var name = arguments[0];
var title = arguments[1];
name = name;
title = title;
var showalert = ("Hi " + name + " your job title is " + title);
console.log(showalert);
return showalert;
}
document.write(mytask("dan", "administrator"));
So your re-deceleration, and assignment is redundant. Anyway - the scope is not changing, nothing else will differ.
Edit
The interpreter goes over your code, with executing anything, any var x = y; statement will split into var x = undefined; and x=y;. And the var x = undefined; will be moved to the top of the code. And the x=y; will be at the same place as the original statement. If you didn't understand the stuff about the stack, don't bother, that's how compilers convert function calls to assembly - it's worth knowing in case you have time; but not THE important thing here.
Anyway - just after those changes, and maybe some optimizations are made, the resulting code is executed. This is not the code you wrote, but an equal one. What you pointed out in redefining the arguments is an edge case where this transformations become visible.
var name = name || 'Jeff';(or, maybe,name = name ? name : 'Jeff';), but only in cases where the paramater's optional.varis not required.