Summary of basic knowledge of JavaScript (1)

This is a recent study note for learning the basics of JavaScript

I am currently learning Web API. If I have time during the study, I will also post my own experience.

1. Introduction to Java Script

JS is divided into three parts:
insert image description here
while the basic syntax of javascript learned belongs to ECMAScript

2. Writing position

Same as CSS, there are three writing locations for JS: inline JS, embedded JS and external JS files
insert image description here
insert image description here
insert image description here

3. Input and output

In JS, the management of input and output is as follows:
insert image description here
only prompt() will pop up a window for the user to output, and both of them are output.
What we need to pay attention to is that the type of prompt input will be converted into a string. If we need other data types, we need to perform data type conversion, which will be discussed below.

Four. Variables

What are variables? Variables are actually equivalent to a container for storing data. We obtain and modify data through variable names.
It is a space that the program applies for in memory to store data, similar to a hotel or a room.

4.1 Use of variables

The first step is to declare the variable. Variables in JS need to be declared.
insert image description here
The second part is to assign values ​​to variables:
insert image description here
Of course, we can also assign values ​​when declaring variables, which we call variable initialization

4.2 Syntax extensions for variables

1. We can declare multiple variables at the same time. For example:

var age = 18,
	name = '鸣人',
	address = '火影村';

Like this, remove the last declared variable, separate each variable with a comma and break on a new line.
2. We usually declare and assign values ​​to variables before outputting. However, consider the following three situations:
a. We only declare and do not assign values?
b. We do not declare, do not assign a value, and use it directly?
c. No declaration, only assignment?
What will be the result of the above three situations?
insert image description here
In the third case, we did not declare direct assignment, which is allowed, but we do not advocate such use, which will make the variable a global variable

4.3 Variable naming convention

insert image description here

Guess you like

Origin blog.csdn.net/qq_45382872/article/details/124307105