JScript Conditional compilation

Source: Internet
Author: User

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;

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.