Chapter II
Data access
Literal:
Represents itself without a specific location: string number bool Object Array function Regular expression
Local variables:
Var
Array:
Stored inside the JS array object, indexed by numbers
Object Members
Stored inside the JS object as a string index
- There are four basic data access locations in javascript: direct volume, variable, array element (indexed by number), object member (with character bed as index)
- Each JS function represents an object, which is a real column of a fun object
- Functions are unique to each execution environment, so calling the same function multiple times will result in multiple execution environments being created
- Each time a variable is encountered, it undergoes an identifier parsing process to determine where to get or where to store the data, and the function method sum Num1 num2 will produce a search process that has a performance impact
- Accessing both the direct and local variables is the fastest, whereas accessing the array elements and object members is relatively slow.
- The deeper the property or method is positioned in the prototype chain, the slower it is to access it.
- In general, you can improve JavaScript performance by using common objects, array elements, and variables stored in local variables.
High-performance JavaScript reading notes-2