Surprising behavior of function parameters default value in JavaScript
```javascript function native(x, f = () => x) { var x; x = 2; return f(); } function compiled(x, f) { if (f === undefined) f = () => x; var x; x = 2; return f(); } native(1); // returns 1 compiled(1); // returns 2 ``` The first function is a simplified version of a quiz question code. I assumed es6 function parameters default values behave just like a check for undefined, which is also basically what babel outputs. I also assumed function parameters are just like any other local variables defined using ```var```. Which means declaring x multiple times using var in the same function shouldn't make a difference (it gets hoisted to the top of the function and doesn't throw any errors) but surprisingly removing the line ```var x;``` from both functions makes them behave the same. Any idea what's going on?