const
declarations for variables that are never reassigned JS-024252 });
53 },
54 onSubmit(event) {
55 let data = formSerialize(event.target, {56 hash: false,
57 empty: true
58 });
36 },
37 methods: {
38 onSubmit(event) {
39 let data = formSerialize(event.target, {40 hash: false,
41 empty: true
42 });
Variables that are never re-assigned a new value after their initial declaration should be declared with the const
keyword.
This prevents the programmer from erroneously re-assigning to a read-only variable, and informs those reading the code that a variable is a constant value.
let pi = Math.PI
for (let x of xs) {
use(x);
}
let { a, b } = object;
use(a, b);
const pi = Math.PI
for (const x of xs) {
use(x);
}
const { a, b } = object;
use(a, b);