当前位置:网站首页>JS input / output statements, variables

JS input / output statements, variables

2022-06-24 00:54:00 51CTO

#1. Output

1.prompt(’ Fill in the contents to be output ‘): Browser pop-up input box , User can input

2.alert(’ Fill in the contents to be output ‘): Pop up warning box , Output 、 Show the , Browser pop-up warning

3.console.log(’ Fill in the contents to be output ‘): Console output , For programmers to test , Browser console printouts

#2. Variable

1. Variable Overview : Variables are containers for storing data , We can get the data through the variable name , Modify and use data , Variables are the memory space that the programmer applies for in memory to store data .

A complete variable consists of a variable name and a storage space .

js I / O statement , Variable _ assignment

 

 

Every time a variable is generated , A space will be generated in our memory , When you store data in variables , The data we write will be stored in memory .

Each variable created is , We all need to generate a name for the variable , When we need to use this variable , You can directly use the variable name to replace the variable

2. Use of variables

  1. Declare variables

   Because the present tense ES6 So we use let Method to declare variables , Variables need to be declared with let For the back Variable name .

  age It is declared by our programmers Variable name .

  2. assignment

   We can use = To assign values to our variable names , Our value is the value to be stored in the variable space  

  js I / O statement , Variable _ The first letter _02

 

3. Variable syntax extension

  1. Update variables

   After a variable has been reassigned , Its original value will be overwritten , The variable value will be subject to the next assignment .

  2. Declare multiple variables at the same time

   When multiple variables are declared at the same time , Just write one let , Multiple variable names are in English ‘ comma ’ separate .

  js I / O statement , Variable _ Variable name _03

 

   3. A special case

  js I / O statement , Variable _ assignment _04

 

4. Variable naming conventions

  1. By letter (A-Za-z)、 Numbers (O-9)、 Underline (_)、 Dollar symbol ($ ) form , Such as : usrAge, num01,_name

  2. Case sensitive .var app; and var App; It's two variables

  3. Cannot start with a number .18age It's wrong.

  4. It can't be a keyword 、 Reserved words . for example : var、for、while

  5. Variable names must have meaning .MMD BBD

  6. Follow the hump nomenclature . Initial lowercase , The first letter of the following words needs to be capitalized .myFirstName

  7. Recommended translation website : youdao   ICIBA


原网站

版权声明
本文为[51CTO]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/175/202206240033120623.html