const
declarations for variables that are never reassigned JS-0242 65 children: PropTypes.node.isRequired,
66 };
67 const downloadCSV = (data, filename) => {
68 let csvData = new Blob([data], { type: "text/csv" }, { encoding: "UTF-8" }); 69 let csvUrl = URL.createObjectURL(csvData);
70 let tempLink = document.createElement("a");
71 tempLink.href = csvUrl;
66 };
67 const downloadCSV = (data, filename) => {
68 let csvData = new Blob([data], { type: "text/csv" }, { encoding: "UTF-8" });
69 let csvUrl = URL.createObjectURL(csvData); 70 let tempLink = document.createElement("a");
71 tempLink.href = csvUrl;
72 tempLink.download = filename;
67 const downloadCSV = (data, filename) => {
68 let csvData = new Blob([data], { type: "text/csv" }, { encoding: "UTF-8" });
69 let csvUrl = URL.createObjectURL(csvData);
70 let tempLink = document.createElement("a"); 71 tempLink.href = csvUrl;
72 tempLink.download = filename;
73 document.body.appendChild(tempLink);
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);