Ad
  • Custom User Avatar

    If you don't declare variables they are automatically global in JavaScript which is bad as it can pollute other code places or even overwrite other variables. It is done here because this code is trimmed to have as few characters as possible (don't know why they use spaces though) and it can be expected that there are no side effects.
    let and const only define the function in the current scope.
    Since function definitions normally don't change it is best to define them with const.

  • Custom User Avatar

    What is the fundamental difference for real code, if in this decision at the very beginning you also write "let". And what is the right way?