When the JS code needs to invoke other JS file methods, it is necessary to use require to introduce other JS files
Cases:
1. Create a new Test.js file on the desktop
CD Desktop
Touch Test.js
2. Enter the JS file
Vim Test.js
3. Input "I" to edit the JS file
For example, enter content:
var a = 12;
Console.log (a);
var subject = CustomFormat ("Now has%s apples" + a),//customformat is a method in Customformat.js, so to introduce the file
4, so to introduce the file in Test.js
If the customformat.js and Test.js directories are the same, for example in this example: CustomFormat. js and Test.js are all on the desktop
So with the path, you can introduce
CustomFormat = require ('./customformat '). CustomFormat;
5, OK, now you can use CustomFormat
6, Beginner JS, there are many do not know the place, one record, Memo.
JavaScript Learn how to use-require