1. Inner Coarse Analysis of Variables
1. Default values for variables
(1) If the variable is not assigned when it is initialized, then the stored variable is undefined
(2) Example
var lk;
console.log(lk);
2. Declare multiple variables at the same time
Two ways
var name,age,sex;
name = "kdfg";
age = 2;
//or
var name = "jsoaf",age,sex = "man";
3. Presentation in memory
Stack memory (hold variables, like Java), heap memory
4. Variable Naming Rules
(1) consisting of letters, numbers and underscores, and cannot start with numbers; (2) case-sensitive; (3) keywords and reserved words cannot be used.
5. How to invalidate a piece of code, or make the compiler think of it as plain text
<script type="text/html"> /** *Use type="text/html" to specify that the contents of this script tag are text, not a piece of code */ </script>
6. Variable naming conventions: follow the hump naming convention
7. Constant Demo
Naming method:
const APO = "Constants can no longer be assigned repeatedly";
8. Summary: Constants and variables are stored in the same way, but constants must have initial values, and values are not allowed to change, while variables can have no initial values and can be changed.
9. Differences between constants and literal values:
Constants and literals are unchanged. Constants are containers for storing data. Literal quantities are values to the right of the equal sign. Literal quantities are strings or values made up of strings, numbers, etc.
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>D3_1_VarityMemoryAnalysis</title> </head> <body> <script type="text/html"> /** *Use type="text/html" to specify that the contents of this script tag are text, not a piece of code */ </script> <script > var lk; console.log(lk);//undefined var name,age,sex; name = "lk"; age = 2; var name1="lk",age,sex="female"; console.log(age,name); //Exchange the values of two numeric variables without using intermediate variables var num1 = 4,num2 = 2; num1 = num1 + num2;//4 + 2 = 6 num2 = num1 - num2;//6 - 2 = 4 num1 = num1 - num2;//6 - 4 = 2 //This completes the exchange without using other variables //Constant Resolution const API = "http://itlike.com"; console.log(API); </script> </body> </html>
2. Data Types
1. Concepts: Programs produce a variety of temporary data during their operation. To facilitate the operation and operation of the data, JavaScript classifies the data and provides rich data types.
2. Classification of data types
(1) Simple data types: Number,String,Boolean,Undefined,Null
(2) Reference (complex) data type: Object
3. Data type view:
(1) the typeof operator: returns the results of the check as strings to them
4.Number
(1) All data in JS is of type Number (integer and decimal)
(2) Due to memory limitations, ECMASript cannot store all the values in the world
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>D3_2_DataType</title> </head> <body> <script> console.log(typeof 10); console.log(typeof "dhsjodf"); console.log(typeof 2.32); //Maximum console.log(Number.MAX_VALUE); //minimum value console.log(Number.MIN_VALUE); //Infinity:Infinity,This value is returned if it exceeds the maximum value console.log(Number.MAX_VALUE + Number.MAX_VALUE); //Infinity:-Infinity,Returns the minimum value if it exceeds it console.log(typeof Infinity); console.log(typeof -Infinity); </script> <script id="String" <script></script> </body> </html>
3. Source code:
D3_1_VarityMemoryAnalysis.html
D3_2_DataType.html
Address:
https://github.com/ruigege66/JavaScript/blob/master/D3_1_VarityMemoryAnalysis.html
https://github.com/ruigege66/JavaScript/blob/master/D3_2_DataType.html
2.CSDN: https://blog.csdn.net/weixin_44630050
3. Blog Park: https://www.cnblogs.com/ruigege0000/
4. Welcome to the WeChat Public Number: Fourier Transform, Personal Account, for technical communication only, Background Reply "Gift Pack" to get Java Big Data Learning Video Gift Pack