content
1.3 The relationship between HTML/CSS/JS
1.8JS input and output statement
2.1 Understanding and storage of variables
2.4 Special cases for declaring variables
2.5 Naming conventions for variables
1. Know JS
1.1 What is JavaScript
1.JS is a scripting language that runs on the client side .
2. The script language does not need to be compiled, and a JS interpreter (JS engine) interprets and executes it line by line during the running process.
(In layman's terms, read line, translate a line )
3. Now it is also possible to perform server-side programming based on Node.js technology.
1.2 The role of JS
The role of JS |
1. Form dynamic verification (password strength detection, the original purpose of JS) |
2. Web page special effects |
3. Server development |
4. Desktop Development |
5.APP |
6. Control Hardware - IoT |
7. Hardware development |
1.3 The relationship between HTML/CSS/JS
1.4 Browser executes JS
1.5 Composition of JS
1.6JS writing position
JS has three writing positions, inline , embedded and chained (external) .
1.7JS annotations
1. //Single line comment vscode Ctrl+l
2. /*Multi-line comment*/ Shortcut key shift+alt+a
1.8JS input and output statement
method | illustrate | belong |
alert | Browser pop-up warning window | browser |
console.log | Browser console printout information | browser |
prompt | An input box pops up, where the user can enter | browser |
2. Variables
2.1 Understanding and storage of variables
1. Variables are containers for storing data
Get data by variable name, even data can be modified
2. Storage of variables in memory
Essence: A variable is a space that a program applies for to store data in memory
2.2 Use of variables
1. Declare the variable var age;
var is a keyword in JS, used to declare variables
age is the variable name, and the allocated space in memory is accessed through the variable name
2. Assign variable initialization
var age = 18 ;
2.3 Variable syntax expansion
1. Update the variable (that is, the variable is reassigned, and the original value will be overwritten)
var age = 20 ;
age=21;
2. You can declare multiple variables at the same time (note that commas are used for separation)
var age = 18 ;
address='I am a programmer Xiaosun',
gz=18888;
2.4 Special cases for declaring variables
Condition | illustrate | result |
var sex ; console.log(sex); |
Only declare, do not assign | undefined |
console.log(tel); | Do not declare, do not assign, use directly | report an error |
qq=110; console.log(qq); |
no declaration, only assignment | 110 <global variable> (can be used, but not recommended) |
2.5 Naming conventions for variables
1. It consists of letters (AZ az), numbers (0-9), underscores (_), dollar signs ($);
2. Cannot start with a number, 18Age is wrong;
3. Variable names must be meaningful (preferably with words)
4. Do not use the name casually
and many more----