![]() Thus, blindly replacing var with let or const is risky. If you replace var with let in the initial version, you get different behavior: let x = 3 ![]() You can see why if you rewrite the code so that it more closely reflects what is actually going on: var x = 3 That func() returns undefined may be surprising. ![]() random() // (A) scope: whole function return x As an example, look at the following ES5 code: var x = 3 ![]() But you shouldn’t do so blindly, because the different kind of scoping can change how code behaves. You can generally replace each var with a let or a const.
0 Comments
Leave a Reply. |