The performance issues of JavaScript cannot be underestimated, which requires us developers to pay more attention to some details when writing JavaScript programs. This article introduces the knowledge points of JavaScript performance optimization in great detail, which is definitely useful information.
Let me first consolidate the basic syntax of javascript:
Basic syntax of javascript
Use the var keyword to define variables
Syntax: var variable name=variable value
identifier: ①, composed of letters, numbers and underscores. It cannot start with a number. It cannot be a keyword. It is strictly case-sensitive
Data type:
Numeric type: number
String: string
Boolean type: boolean
Special data types: undefined empty undefined unassigned
Null value: null
Reference type object function
Detect the data type of the parameter: typeof() returns the string corresponding to the data type
Usage of two equal signs == and three equal signs ===
==: Comparison values are equal regardless of data type
===: Congruent comparison is related to both numerical values and data types
Boolean environment: automatically convert to Boolean value when encountering if
Boolean environment in string string: empty is false, non-empty is true
Boolean environment in numerical number: 0 is false, non-0 is true
The relationship between number and string
①. When encountering, perform splicing operation
②. When operations need to be performed, the string must be converted into a numerical value
Conversion method 1, string*1 into numeric type
Conversion method 2: Convert Number (string) to numeric type
1: Loading location of js files
In HTML files,