0

My html file include two JavaScript files, the function in one .js file need to call the function in other file.

This is the HTML code:

<script type="text/javascript" src="1.js"></script>
<script type="text/javascript" src="2.js"></script>

This is the function which will be called in '1.js':

function add (val) {
 return val+1;
}

This is the function in '2.js' which will call other function:

function selfAdd (val) {
 add(val);
}

When I use JShint to lint '2.js', it report error "the 'add' is not defined."

According to my understanding, in JavaScript one file is allowed to call functions in other file if both of them are included in one html file,doesn't it? If it does, how can I delete this error information? Thank you for help.

Zhe Li
  • 1
  • 2
  • 1
    JShint doesn't know that you're going to be loading the other file first, so it doesn't know that the function will be defined. – Barmar Aug 19 '16 at 00:53
  • 1
    So are you running it against one file or the html file? http://stackoverflow.com/questions/7628009/jslint-with-multiple-files – epascarello Aug 19 '16 at 00:54

0 Answers0