Writing high-quality code: 188 Tips for improving JavaScript programs learn little (i)

Source: Internet
Author: User
Tags bitwise operators

Author Introduction:

Shing Lum, a senior web front-end engineer who has worked in the Web front-end for many years, is proficient in web front-end technologies such as CSS, HTML, JavaScript, jquery and Ajax, and has accumulated a lot of experience in practice. Respected web technology standards, has been in a number of universities and some offline technology salons to the Web standards and norms related courses, has been involved in the standardization of the Organization of the Chinese language compilation of documents. In recent years, focus on research and practice CSS3 and
HTML 5 Frontier Technology, is one of the pioneers in this field in China.

The catalogue of the books is categorized in the following sections:

The 1th chapter JavaScript language Basics

2nd. Strings, regular expressions, and arrays

3rd Chapter Functional Programming

The 4th Chapter object-oriented programming

5th Chapter DOM Programming

The 6th Chapter client programming

Chapter 7th Data Interaction and storage

8th JavaScript engine and compatibility

The 9th Chapter JavaScript programming specification and application

Specific catalogue

The 1th chapter JavaScript language Basics
Recommendation 1: Beware of Unicode garbled characters
Recommendation 2: Correct analysis of words, sentences and segments in JavaScript syntax
Recommendation 3: Reduce global variable contamination
Recommendation 4: Note the specificity of JavaScript data types
Recommendation 5: Prevent JavaScript from automatically inserting semicolons
Recommendation 6: Correctly handle JavaScript special values
Recommendation 7: Be careful to retain the misuse of words
Recommendation 8: Use operators with caution
Recommendation 9: Don't trust hasOwnProperty
Recommendation 10: Remember object non-empty attributes
Recommendation 11: Using pseudo-arrays with caution
Recommendation 12: Avoid using with
Recommendation 13: Develop a way of thinking about optimal expressions
Recommendation 14: Do not misuse eval
Recommendation 15: Avoid using continue
Recommendation 16: Prevent switch from running through
Recommendation 17: Block flags are not superfluous
Recommendation 18: Comparing function statements and function expressions
Recommendation 19: Do not use the Type Builder
Recommendation 20: Do not use new
Recommendation 21: Recommend strategies to improve cycle performance
Recommendation 22: Use less function iterations
Recommendation 23: Recommended strategies for improving conditional performance
Recommendation 24: Optimize if logic
Recommendation 25: Properly Select if and switch
Recommendation 26: Be careful if nested thinking traps
Recommendation 27: Be careful if hidden bugs
Recommendation 28: Use the look-up table method to improve the performance of condition detection
Recommendation 29: Accurate use of the loop body
Recommendation 30: Using recursive mode
Recommendation 31: Using iterations
Recommendation 32: Using watchmaking
Recommendation 33: Optimizing the looping structure
2nd. Strings, regular expressions, and arrays
Recommendation 34: String non-value operation
Recommendation 35: Get the byte length
Recommendation 36: Beware of string connection operations
Recommendation 37: Use Replace is recommended
Recommendation 38: Correct understanding of the working mechanism of regular expressions
Recommendation 39: Correct understanding of regular expression backtracking
Recommendation 40: Correctly use regular expression grouping
Recommendation 41: Proper use of regular expression references
Recommendation 42: Use good regular expression static values
Recommendation 43: Use Exec to enhance regular expression functionality
Recommendation 44: Use atomic groups correctly
Recommendation 45: Beware of nested quantifiers and runaway backtracking
Recommendation 46: Improve the efficiency of regular expression execution
Recommendation 47: Avoid scenes that use regular expressions
Recommendation 48: Use regular expressions sparingly to trim strings
Recommendation 49: Comparing arrays to object homology properties
Recommendation 50: correctly detect array types
Recommendation 51: Understanding the limitation and infinity of array lengths
Recommendation 52: We recommend that you use splice to delete an array
Recommendation 53: Use the array dimension with care
Recommendation 54: Sort function to enhance array sorting
Recommendation 55: Don't stick to the digital subscript
Recommendation 56: Using arguments to simulate overloading
3rd Chapter Functional Programming
Recommendation 57: Disable the function constructor
Build 58: Flexible use of arguments
Recommendation 59: Recommend dynamic call functions
Recommendation 60: compare function call Patterns
Recommendation 61: Cross-domain development with closures
Recommendation 62: Careful use of closures in loop body and asynchronous callbacks
Recommendation 63: Comparing function calls and referential nature
Recommendation 64: Recommended by Function Extension type
Recommendation 65: Lazy evaluation and non-inert evaluation of comparison functions
Recommendation 66: Using functions to implement history
Recommendation 67: Apply a function
Recommendation 68: Use chained syntax recommended
Recommendation 69: Using modularity to circumvent defects
Recommendation 70: Lazy instantiation
Recommendation 71: Recommend branch functions
Recommendation 72: Lazy load function
Recommendation 73: Function binding is valuable
Recommendation 74: Using higher-order functions
Recommendation 75: Function currying
Recommendation 76: Pay attention to function throttling
Recommendation 77: Recommend a scope-safe constructor
Recommendation 78: Understanding the execution context and scope chain correctly
The 4th Chapter object-oriented programming
Recommendation 79: Refer to the object construction system analysis prototype mechanism
Recommendation 80: Rational use of prototypes
Recommendation 81: The prototype domain chain is not a scope chain
Recommendation 82: Do not retrieve object property values directly
Recommendation 83: Using a prototype delegate
Recommendation 84: Prevent prototype reflection
Recommendation 85: Handle the scope of the object with caution
Recommendation 86: Using object-oriented impersonation inheritance
Recommendation 87: Resolving this and function call relationships
Recommended 88:this is a dynamic pointer, not a static reference
Recommendation 89: Correct application of this
Recommendation 90: Prevent this misuse of the policy
Recommendation 91: Recommend using the constructor prototype schema to define classes
Recommendation 92: Use of prototype inheritance is not recommended
Recommendation 93: Using Class inheritance is recommended
Recommendation 94: Using encapsulation class inheritance is recommended
Recommendation 95: Use instance inheritance with caution
Recommendation 96: Avoid using replication inheritance
Recommendation 97: Recommended use of hybrid inheritance
Recommendation 98: Compare the use of JavaScript polymorphism, overloading, and overwrite
Recommendation 99: Recommend active encapsulation classes
Recommendation 100: Use the static members of a class with caution
Recommendation 101: Compare the construction and destruction characteristics of a class
Recommendation 102: Using the Enjoy meta class
Recommendation 103: Using a mixed class
Recommendation 104: Use pseudo-classes with caution
Recommendation 105: Compare the two modes of a single case
5th Chapter DOM Programming
Recommendation 106: It is recommended to first detect the extent of browser support for DOM
Recommendation 107: The HTML should be cleared
Dom Loading process
Recommendation 108: Careful access to the DOM
Recommendation 109: Compare innerHTML with standard DOM methods
Recommendation 110: Beware of whitespace bugs in document traversal
Recommendation 111: Cloning a node is better than creating a node
Recommendation 112: Use HTML collections with caution
Recommendation 113: Accessing collection elements with local variables
Recommendation 114: Grab the DOM using nextsibling
Recommendation 115: Implement a DOM prototype inheritance mechanism
Recommendation 116: Using CSS selectors is recommended
Recommendation 117: Reduce DOM redraw and re-typesetting times
Recommendation 118: Use the DOM tree structure to host events
Recommendation 119: Using timers to optimize the UI
Queue
Recommendation 120: Use timer decomposition tasks
Recommendation 121: Run code with timer limit
Recommendation 122: Recommended Web worker threads
The 6th Chapter client programming
Recommendation 123: Compare IE and event streams
Recommendation 124: Design a drag-and-drop scheme for your mouse
Recommendation 125: Design the mouse pointer positioning scheme
Recommendation 126: Be careful to position the mouse pointer inside an element
Recommendation 127: Proper use of the domcontentloaded event
Recommendation 128: Recommended use of the Beforeunload event
Recommendation 129: Custom Events
Recommendation 130: Extracting element dimensions from a CSS style sheet
Recommendation 131: Careful use of offsetwidth and offsetheight
Recommendation 132: Calculate the area size correctly
Recommendation 133: Calculate the scrolling area size carefully
Recommendation 134: Avoid calculating window sizes
Recommendation 135: Get the absolute position correctly
Recommendation 136: Get the relative position correctly
Chapter 7th Data Interaction and storage
Recommendation 137: Use a hidden framework for asynchronous communication
Recommendation 138: Use an IFRAME for asynchronous communication
Recommendation 139: Using script to implement asynchronous communication
Recommendation 140: Correct understanding of the JSONP Asynchronous communication protocol
Recommendation 141: Compare common Server Request methods
Recommendation 142: Compare common methods of sending data to a server
Recommendation 143: Avoid using XML format for communication
Recommendation 144: We recommend using JSON format for communication
Recommendation 145: Use HTML format sparingly for communication
Recommendation 146: Use a custom format for communication
Recommended 147:ajax Performance Wizard
Recommendation 148: Use local storage data
Recommendation 149: Beware of DOM-based cross-domain intrusion
Recommendation 150: Best Practices for optimizing AJAX development
Recommendation 151: Data storage to consider access speed
Recommendation 152: Storing data using local variables
Recommendation 153: Beware of man-made changes to the scope chain
Recommendation 154: Use dynamic scopes with caution
Recommendation 155: Beware of closures leading to memory leaks
Recommendation 156: Flexible use of cookies to store long information
Recommendation 157: Recommended Encapsulation Cookie Application interface
8th JavaScript engine and compatibility
Recommendation 158: Compare mainstream browser kernel parsing
Recommendation 159: Recommend detection based on browser features
Recommendation 160: Focus on the various engines on ECMAScript
V3 's Disagreement
Recommendation 161: Focus on the various engines on ECMAScript
V3 's Supplement
Recommendation 162: Focus on different engines ' differences in event resolution
Recommendation 163: Focus on the differences between the various engines on DOM parsing
Recommendation 164: Focus on different engines ' differences in CSS rendering
The 9th Chapter JavaScript programming specification and application
Recommendation 165: Do not confuse JavaScript with the browser
Recommendation 166: Mastering the JavaScript pre-compilation process
Recommendation 167: Accurately analyze JavaScript execution order
Recommendation 168: Avoid two evaluations
Recommendation 169: Use of direct quantities is recommended
Recommendation 170: Don't let the JavaScript engine work again
Recommendation 171: Use bitwise operators to perform logical operations
Recommendation 172: Using native methods is recommended
Recommendation 173: Write a non-blocking JavaScript script
Recommendation 174: Delay the execution of the script
Recommendation 175: Using XHR Script injection
Recommendation 176: Recommend optimal non-blocking mode
Recommendation 177: Avoid deep scope access
Recommendation 178: Recommended JavaScript performance tuning
Recommendation 179: Reduce repaint and reflow in DOM operations
Recommendation 180: Improve DOM access efficiency
Recommendation 181: Use
SetTimeout Implementing worker threads
Recommendation 182: Use the Web
Worker
Recommendation 183: Avoid memory leaks
Recommendation 184: Use SVG to create dynamic graphics
Recommendation 185: Reduce access to Object members
Recommendation 186: Recommended 100
MS User Experience
Recommendation 187: Using interfaces to resolve JavaScript file conflicts
Recommendation 188: Avoid JavaScript conflicts with CSS

Writing high-quality code: 188 Tips for improving JavaScript programs learn little (i)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.