Doubt about the default value of ES6 function parameters

clipboard.png

Why do I get an error when I use var outside? You won"t make a mistake in it?

function fn(x=8){
  var x = 89;
  console.log(x);//
}
fn();
let y = 7;
var y = 8;//
Apr.25,2021
The parameters of the

function are equivalent to the variables from var. The repeated definition of var will not report an error


because on the outside
you declare y
you declare y
if you declare y with var


let/const forbids variable promotion

Menu