Microsoft's explanation of conditional compilation is:
Some typical uses of conditional compilation include using new features in Jscript, embedding debugging support in scripts, and tracking the execution of code.
First look at a piece of code to understand briefly:
var s=0//@cc_on 1
alert(s)
If If you are using IE, you can see that the value of s prompted by the browser is "1";
var s=0//@cc_on 1
is equivalent to:
var s=0 1
Conditional compilation provides a way to run code in comments.
Generally, we rarely use conditional compilation when writing JavaScript code. However, due to its own characteristics, conditional compilation provides convenience for our detection system and automatic identification of browser programming.
There is a very classic code:
var isMSIE = /*@cc_on!@*/false;
It can also be like this:
var IE=0//@cc_on 1
More complicated:
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;