Basic knowledge of JavaScript Q &

Source: Internet
Author: User
JavaScript annotation Method 9. JavaScript annotation (Comments in JavaScript)
Q: How do I insert comments in JavaScript code?
A: JavaScript supports three different types of Annotations:
Comments of the multi-line C style. The content included in/* and */is annotated, for example:
/* This is a comment */
/* C-style comments can span
As your lines as you like,
As shown in this example */
Single line comment of the C ++ style. These comments start with // and end with the end of the line:
// This is a one-line comment
Start the sequence with HTML annotation ( ). Consider this instance:
This is also a one-line JS comment
Because JS ignores the closing characters
Of HTML-style comments
HTML style annotations are not common in JavaScript code. (// Single-line comments guided are simpler and easier to read ). However, we strongly recommend that you use HTML annotations to hide JavaScript code from an earlier browser.
10. Hide the JS code from the old browser (Hidding JS code from old browsers)
Q: How can I hide JS Code from an old version that does not support JavaScript?
A: To prevent older browsers from displaying JS code, you can use the following methods:
After the script label starts with, immediately add a line of the HTML style comment start style, there is no end content, so the first two lines of your script should look like:

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.