Front-end notes (3. JavaScript 2)

Source: Internet
Author: User

In general, the JS code is more and more large, it is best to put it in a JS file,

can be introduced via SRC, which is highly maintainable and cacheable (load once without loading)

Features to facilitate future expansion

Correct wording:

<script type= "Text/javascript" src= "Test1.js" ></script>

Error wording:

<script type= "Text/javascript" src= "Test1.js"/>

And you can't add any code in there.

<script type= "Text/javascript" src= "Test1.js" >alert ("Cannot execute");</script>

If there is nothing in the double label, you can add it directly.

Smooth degradation does not support js:<noscript>

The core of JS is Emascript

I. Grammatical composition

Case sensitive

An identifier is the name of a variable function property, or a function's argument, which can be:

    1. The first character must be a letter, underscore, or dollar sign
    2. Other characters can be alphanumeric underscores or dollar signs
    3. Cannot put keywords, reserved words, true,false and null as identifiers

Block-level annotations/**/

Direct volume (literal constant literal)

So the direct amount is the data value that is displayed directly in the program.

100//Digital literal

' Ljmz '//character literal

False//Boolean literal

/js/gi//Regular expression literals

Null//Object literal

Expressions for array literals and object literals are supported:

{X:1,y:2}

{1,2,3,4,5}

Ii. keywords and reserved words

ECMAScript describes a set of keywords that are used for a specific purpose, typically for controlling the start or end of a statement

Or to perform a specific operation, and so on. Keyword is also language reserved and cannot be used as an identifier

ECMAScript also describes a set of reserved words that cannot be used as identifiers, although reserved words have no specific use in JS

, but they are likely to be used as a keyword in the future.

Third, variable

Variables are loosely typed, so-called loose types are used to hold any type of data. When defining variables

To use the var operator, followed by a variable name, which is the identifier

var box

The box variable is defined, but it is not initialized, and the system gives it a special value-undefined

(denotes undefined)

The so-called variable is the amount that can be initialized and then changed, and the ECMAScript belongs to the weak type (loose type)

Language, you can change the amount of different types simultaneously (PS: Although you can change the amount of different types,

Late maintenance is difficult, and performance is not high, resulting in high costs! )

var stt= "Ljmz"

stt=100;

alert (STT);

View variable type: typeof variable name

Front-end notes (3. JavaScript 2)

Related Article

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.