Changes between Version 4 and Version 5 of Ticket #6581, comment 10


Ignore:
Timestamp:
04/14/2018 02:04:19 AM (20 months ago)
Author:
sebastian
Comment:

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #6581, comment 10

    v4 v5  
    1 I personally don't care about `const` in JavaScript. It's advantages (if any) are negligible. JavaScript engines do NOT benefit from it, since the JIT compiler already knows if a variable will be changed or not regardless how it was declared. It's mostly a hint for developers, indicating that a variable isn't re-assigned. How useful this information is is highly subjective. While some developers believe that they can better understand code if its obvious from the declaration of a variable whether it will ever be re-assigned, any language feature makes the language more complex. It's one more thing you have to think about, whether to use `const` or `let`, when writing code. Also when changing existing code and a variable that was defined `const` before, now needs to be re-assigned, you might find yourself changing variable declarations from `const` to `let` (and potentially later back to `const`), all the time. 
     1I personally don't care about `const` in JavaScript. It's advantages (if any) are negligible. JavaScript engines do NOT benefit from it, since the JIT compiler already knows if a variable will be changed or not regardless how it was declared. It's mostly a hint for developers, indicating that a variable isn't re-assigned. How useful this information is is highly subjective. While some developers believe that they can better understand code if its obvious from the declaration of a variable whether it will ever be re-assigned, any language feature makes the language more complex. It's one more thing you have to think about, whether to use `const` or `let`, when writing code. Also when changing existing code and a variable that was defined with `const` before, now needs to be re-assigned, you might find yourself changing variable declarations from `const` to `let` (and potentially later back to `const`), all the time. 
    22 
    33Anyway, what is more important here, is having a rule that is unambiguous, easy to enforce consistently, and avoids subjective debates in code reviews. This leaves us with any of the following options: