Issues that should be considered when writing code in web development [Miscellaneous]

  1. Before writing the code, you must design it first, draw a picture by yourself, and then do it after you think about it.
  2. When writing standardized code, you should consider the clarity of logic, the readability of the code, and the maintainability of the code, so as to facilitate the debugging of the code later.
  3. Most of the time, you can specify the width of the elements for placing content in the website, and the height of the elements can be supported by the height of the content.
  4. Each partition in the web page layout is wrapped in a div to divide the area
  5. Consider the picture overflowing or not taking up space. Set img: width: 100%; vertical-align: middle;
  6. Get the style of the element: window.getComputedStyle(this).getPropertyValue("background-position")
  7. In the chrome browser, hold down the shift key and click the color block in the developer tool to switch between different color representation methods
  8. Consider the waste of code, we should streamline our code
  9. Access speed of the code: the code is compressed, line breaks, spaces and comments need to be deleted, we don’t need to manually, we can install plug-ins
  10. Repetitive code must be bound to a function, encapsulated for multiple use
  11. The smallest font on the web page is 12px. If you set a smaller font size, it will become 12px.
  12. The naming of the file should be standardized, do not appear ()
  13. The attributes of the element, name and class are best written in the front
  14. The js code is still wrapped in functions, and does not affect the namespace of global variables
  15. Note that a semicolon must be added after each statement, do not let the program add a semicolon, waste time
  16. Different closing methods of the clicked interface, such as clicking the blank space to close the drop-down box opened by the button, considering the user experience
  17. It is very important to use the class to modify the style of the element, we must pay attention to the priority of the style
  18. When we use variables to save, we only need to read the variables, which means that access to elements and calculations only need to be done once
  19. Use the closure to save the current index, or define an attribute to save the current index, two methods to get the index value
  20. Executing the function definition will produce a closure (without calling the function)
  21. Use uncompressed during development (testing) phase, use compressed version when online
  22. Anonymous function calls itself, returns an object, and uses closures to expose some functions and methods for modular development
  23. Arguments implements function overloading, passing in one or more parameters, the disadvantage is that it is a pseudo-array
  24. The functions in the for loop are executed after the for loop is executed.
    The short-circuit operation implementation function does not pass parameters and uses default values, but if the value passed by the user is 0, the user’s expectations will not be achieved. At the same time, we can also set default values ​​for the parameters

Guess you like

Origin blog.csdn.net/Serena_tz/article/details/113680393