These are some of my experiences in code writing. I have summarized them and I want to share them with you. I just wrote them when I think of them.
1. Use local variables to avoid using global variables
For example
Change
The advantage of local variables is that it reduces the scope chain search.
I suggest using local variables if there are two references.
2. Avoid using with (everyone on Earth knows this)
The reason I understand is that with will create its own scope, which prolongs the original scope chain and slows down the code executed in the with block. It seems that the code is saved in writing, in fact, access becomes longer and more complex, and performance decreases.
Example
Use
In fact, they can all be written
3. Traverse nodelist
Generally
(Note: This method can be used in nodelist. If you use array, there may be a problem. If there is a 0 in the array, the latter is null or something will be blind)
- Three pages in total:
- Previous Page
- 1
- 2
- 3
- Next Page