Avoid-Using-Var¶
Sourcery rule id: avoid-using-var
¶
Description¶
Use const
or let
instead of var
.
Match¶
var a = 1
Explanation¶
const
is preferred as it ensures you cannot reassign references (which can lead to buggy and confusing code).
let
may be used if you need to reassign references - it's preferred to var
because it is block- rather than
function-scoped.
From the Airbnb JavaScript Style Guide