JS: Default function parameter values and scope
问题 I'm a bit confused about how scope & variable assignment within a function seems to change when assigning a default parameter value for that function. For example, when this function has a default value assigned to parameter i , the output array variable appears to be block-scoped when inspected with Chrome Dev Console,: function steps(n, i = 40) { var output = [n]; } steps(10, 20); However, by removing the default parameter value for i , the output array variable is scoped locally: function