1 JavaScript Introduction
1.1 JS is a web programming language that runs on the client.
1.2 Components
(1) ECMAScript: ECMAScript is not a language, but a standard. The more common criteria are: JavaScript, Action Script (language in Flash)
(2) DOM: JavaScript API for manipulating elements on Web pages
(3) BOM: JavaScript API to manipulate some of the features of the browser
1.3 Features
(1) Easy to use
Can be written using any text editing tool, only the browser is required to execute the program
(2) Interpretation of execution (interpretation of language)
Do not compile in advance, execute line by row, without strict variable declaration
Compile execution: read. dll executable file ==> computer as Java C # conversion to. dll executable file
(3) Object-based
Built-in large number of ready-made objects, writing small programs to accomplish goals
2 JS Writing position
(1) Embedded type
(2) External chain type
The JavaScript code is written to another file (the suffix is usually ". js"), which is then embedded in the document in the format "<script src=" Javascript.js "></script>".
After the <script> tag appears in the HTML page, the page pauses to wait for parsing and execution of the script. Whether the current script is inline or out-of-the-box, the download and rendering of the page must stop waiting for the script to complete before it can continue, which is necessary for the life of the page.
1: Because the page load script blocks the download of other resources, it is recommended to place all the script tags at the bottom of the body tag, reducing the impact on the entire page download
2: Merge the JS files that can be merged
3 several ways to output messages
3.1 Escape characters
\ "Turn double lead
\ ' Turn single citation
\ n Convert rows
\ r turn to enter
3.2 JS Comment
Shortcut key ctrl+/
Single-line comment//
Multiline Comment/* */
4 variables
Naming conventions:
Variable names must begin with a character or underscore "_"
Variables can contain numbers, letters from A to Z
JavaScript is strictly case-sensitive, computer and computer are two completely different variables
Disallow the use of JavaScript keywords and reserved words as variable names.
Key Words: The JavaScript language is used to program or perform specific operations on English words.
Reserved words: In the ECMAScript specification, certain words are reserved so that they can be used for keywords at a later time.
5 Data types
(1) Math type: number)
1: The most basic data type
2: no distinction between integral and floating-point values
3: The maximum value that can be represented is ±1.7976931348623157 times 10 of the 308-square
The minimum value that can be expressed is ±5 times 10-324
4: Contains 16 binary data, with a number starting at 0x 0 to 9, a (a)-F (f) between the letters. A-f the corresponding number is 10-15
5: Octal directly starts with the number 0 and has a number of 0-7.
(2) String type: string
strings are enclosed by single or double quotation marks
For example, a single letter is also called a string (for example: ' A ')
escape character \ ' \ '
(3) Boolean type: Boolean
Only 2 values one is true and the other is false. True=1,false=0 in the actual operation
(4) JavaScript special type
Judging data types with typeof ()
1. Value null meaning: A keyword in JavaScript that represents a special value. Typically used to describe "null values".
2, value undefined meaning: The variable is defined, but the variable is not initialized (the variable is not assigned), indicating the vacancy of the value. In EcmaScript3, undefined is a read-write variable that can be assigned any value. This error has been modified in ECMASCRIPT5. Only undefined this one value.
In JavaScript, the process of executing a program is performed from top to bottom. An error is encountered and will not be executed further down.
JavaScript Basics (1)