Changes between Version 51 and Version 52 of Coding_Conventions


Ignore:
Timestamp:
May 17, 2021, 5:54:28 PM (3 years ago)
Author:
Freagarach
Comment:

Phab:rP25454.

Legend:

Unmodified
Added
Removed
Modified
  • Coding_Conventions

    v51 v52  
    412412}}}
    413413
    414  * Use `var` only when declaring variables in the global scope. When inside functions, ifs, loops, etc., use `let`. We prefer `let` because:
     414 * Use `var` only when declaring variables in the global scope. When inside functions, ifs, loops, etc., use `let` or `const`. We prefer `let` because:
    415415   - It is restricted to the scope it is declared in, preventing unintentional clobbering of values
    416416   - It is stricter than `var`, and throws an error if it a variable is declared twice within the same scope
     
    427427}
    428428}}}
     429   - We prefer `const` when the value is not intended to be changed. This allows easier readability and is considered good practice to prevent accidental changing of values.
    429430
    430431