once the default value of the parameter is set, the parameter forms a separate context when the function is declared to initialize. When initialization is complete, the scope disappears. This syntax behavior is not an extension of the
function when the parameter default value is not set.
var x = 1;
function foo(x, y = function() { x = 2; }) {
let x = 3;
y();
console.log(x);
}
foo() // Uncaught SyntaxError: Identifier "x" has already been declared
Why is it feasible to declare the same parameter variable with var inside the function, and overwrite the variable with the same name in the parameter; but if you use let or const, you will report an error. I can understand the use of let and const, because the argument is equivalent to declaring with let x, and then declaring it with let will report an error