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:
- The first character must be a letter, underscore, or dollar sign
- Other characters can be alphanumeric underscores or dollar signs
- 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)