How to check errors after simplifying this situation: open the script error prompt of IE, then open the HTML page calling JS, it will report the location where the missing semicolon is located, then use UE to open the thin JS file, go to the corresponding location and add a semicolon, and then find the corresponding location in the unsimplified JS code to add a semicolon.
For example:
The code copy is as follows:
var a=1
var b=2
Change to:
The code copy is as follows:
var a=1;
var b=2;
◆Try to use braces in the statements after else
This situation is more troublesome to check incorrectly. Use the regular expression else[a-zA-Z0-9]+ to find the streamlined JS file, or find whether there are commented lines after else, and then find the corresponding position in the unsimplified JS code with curly braces.
For example:
The code copy is as follows:
if (a>b)
a=b;
else
b=a;
Change to:
The code copy is as follows:
if (a>b)
a=b;
else
{b=a}
◆Try to add semicolons after the function's reverse braces
For example:
The code copy is as follows:
function a() {
}
function b() {
}
Change to:
The code copy is as follows:
function a() {
};
function b() {
};
This way, the problem of errors after compression can be solved.
At the same time, pay attention to the problem of Chinese garbled code. You can use copy and paste without saving as a file.
window.load = function()
{
}
If defined in this way, there must be a semicolon at the end.