problem description:
I have two js files
I defined one of this function in the first js file
function formHeader (msg) {
let formHeaderContent = `
<caption>${msg}</caption>
<tr>
<th></th>
<th></th>
<th>1</th>
<th>2</th>
<th>3</th>
<th>4</th>
<th>5</th>
<th>6</th>
<th>7</th>
<th>8</th>
<th>9</th>
<th>10</th>
<th>11</th>
<th>12</th>
</tr>`;
return formHeaderContent;
}
in the second .js
function renderForm(data, msg) {
// :12 12
// {
// HTML
// }
// HTMLtable-wrapper
const formHeader = formHeader(msg);
....
}
wrote one of this function, and then mistakenly reported Uncaught ReferenceError: formHeader is not defined
this is how I understand : my function is declared and defined in the global of another js file, why does it report an error undefined? here? My understanding is that both .js belong to a global environment, I am in one of the .js life functions, the other .js should also be able to call it, I do not know where to understand the problem
what is the difference between it and this function?
function abc(val) {
return val;
}
var abc = abc("hello") //