Microsoft interprets Conditional compilation as follows:
Some typical uses of Conditional compilation include the use of new features in JScript, embedded debugging support in the script, and tracking Code.
Let's take a look at a simple piece of code:
VaR S = 0 // @ cc_on + 1
Alert (s)
If you are using IE, you can see that the browser prompts that the value of S is "1 ";
VaR S = 0 // @ cc_on + 1
In IE, it is equivalent:
VaR S = 0 + 1
Conditional compilation provides a way to run code in annotations.
In general, Conditional compilation is rarely used when writing JavaScript code. However, due to its own characteristics, Conditional compilation provides convenience for detecting the system and automatically identifying browser programming.
There is a piece of classic code:
VaR ismsie =/* @ cc_on! @ */False;
You can also do this:
VaR Ie = 0 // @ cc_on + 1
More complex:
VaR ieversion =/* @ cc_on function () {Switch (@ _ jscript_version) {Case 1.0: return 3; Case 3.0: return 4; Case 5.0: return 5; Case 5.1: return 5; Case 5.5: Return 5.5; Case 5.6: return 6; Case 5.7: Return 7 ;}} () | @ */0;