Writing high-quality code: 188 suggestions for improving javascript programs

Source: Internet
Author: User

Writing high-quality code: 188 suggestions for improving javascript programs
This information
Author: Cheng Lin
Press: Machinery Industry Press
ISBN: 9787111399056
Mounting time:
Published on: February 1, January 2013
Start: 16
Page number: 1
Version: 1-1
Category: Computer> Software and programming> network programming> Javascript

More about writing high-quality code: 188 suggestions for improving javascript programs
Introduction
Books
Computer books
"Writing high-quality code: 188 suggestions for improving javascript programs" is a must-read task for advanced Web Front-end engineers. It will help you navigate to the "javascript technology hall! All content is composed of the best practices for writing high-quality JavaScript code, provides an empirical solution to the problems encountered by Web Front-end engineers in terms of basic syntax, application architecture, tool framework, encoding style, and programming ideology, it provides 188 extremely valuable suggestions for Web Front-end engineers on how to write higher-quality JavaScript code. For each problem, we not only provide a solution that has been proved to be excellent in practice, but also provide a solution that is often misused or misunderstood, the analysis and comparison are made from both positive and negative aspects, just as if they were very straightforward.
Writing high-quality code: 188 suggestions for improving javascript programs the application scenarios designed for each problem are very typical, and the suggestions are also closely integrated with practices. Every suggestion in the book may be used in your next line of code, next application, or next project. It is recommended that you keep this book at hand for reference at any time, it will surely make your learning and development work more efficient.
Directory
Writing high-quality code: 188 suggestions for improving javascript programs
Preface
Chapter 1 basics of JavaScript language/1
Recommendation 1: Be cautious with Unicode garbled characters/1
Suggestion 2: correctly differentiate words, sentences, and segments in Javascript syntaxes/2
Recommendation 3: Reduce global variable pollution/4
Suggestion 4: Pay attention to the particularity of JavaScript data type/6
Suggestion 5: Prevent Automatic insert of semicolons/11 in Javascript
Suggestion 6: Correct Processing of special JavaScript values/12
Suggestion 7: exercise caution when reserved words are misused/15
Recommendation 8: exercise caution when using the operator/16
Recommendation 9: Do not trust hasownproperty/20
Recommendation 10: Keep in mind the non-empty object feature/20
Recommendation 11: use pseudo array/21 with caution
Recommendation 12: Avoid using with/22
Suggestion 13: Develop the thinking mode for optimizing expressions/23
Recommendation 14: Do not abuse eval/26
Suggestion 15: Avoid using continue/27
Suggestion 16: Prevent switch penetration/28
Suggestion 17: block flag is not redundant/29
Suggestion 18: Compare function statements and function expressions/29
Recommendation 19: Do not use the Type constructor/30
Suggestion 20: Do not use new/31
Recommendation 21: recommended strategy for improving cyclic performance/31
Recommendation 22: less Function Iteration/35
Recommendation 23: We recommend a policy to improve the conditional performance/35
Suggestion 24: optimize if logic/36
Suggestion 25: Select if and switch/39
Suggestion 26: Be careful with if nested thinking traps/40
Suggestion 27: Be careful with if hidden bugs/42
Recommendation 28: Use the Lookup Table Method to Improve the Performance of condition detection/43
Recommendation 29: Use the loop body accurately/44
Suggestion 30: Use recursive mode/48
Recommendation 31: Use iterations/49
Recommendation 32: Tabulation/50
Recommendation 33: optimize the Cycle Structure/51
Chapter 3 string, regular expression, and array/53
Recommendation 34: non-value string operation/53
Suggestion 35: Get the byte length/55
Suggestion 36: Be cautious with string connection operations/56
Recommendation 37: replace/59 is recommended.
Suggestion 38: Correct Understanding of the regular expression working mechanism/62
Recommendation 39: Correctly Understand Regular Expression backtracking/63
Suggestion 40: correct use of regular expression grouping/65
Suggestion 41: use regular expression to reference/68
Suggestion 42: use regular expressions for static values/69
Recommendation 43: Use exec to enhance the Regular Expression Function/71
Recommendation 44: correct use of atomic groups/72
Suggestion 45: guard against nested quantifiers and out-of-control backtracking/73
Recommendation 46: Improve the execution efficiency of Regular Expressions/74
Recommendation 47: Avoid using regular expressions/76
Suggestion 48: use regular expressions with caution to trim strings/77
Suggestion 49: Compare the same-source features of arrays and objects/80
Suggestion 50: Check the array type correctly/81
Suggestion 51: Understand the limitation and infinity of array length/82
Suggestion 52: We recommend that you use splice to delete the array/83
Suggestion 53: Use array dimension with caution/84
54. Suggestion: Enhance the sort function of array Sorting/85
Suggestion 55: Do not stick to the number subscript/87
Recommendation 56: use arguments to simulate overloading/89
Chapter 1 functional programming/91
Recommendation 57: Disable function constructor/91
Build 58: flexible use of arguments/94
Recommendation 59: dynamically call functions/96
Suggestion 60: Compare the function call mode/99
Suggestion 61: Use closure for cross-origin development/101
Recommendation 62: Use closure/104 with caution in the loop body and asynchronous callback
Recommendation 63: Compare the nature of function calls and References/106
Recommended 64: Function Extension Type/108
Recommendation 65: Evaluate the inertia and non-inertia of the comparison function/109
Recommendation 66: Use the function to implement historical records/111
Recommendation 67: Apply a function/113
Recommendation 68: chained syntax/114
Recommendation 69: Use modularization to avoid defects/115
Recommendation 70: inert instantiation/117
Recommendation 71: Recommended Branch functions/118
Recommendation 72: inert Loading Function/119
Recommendation 73: function binding valuable/121
Recommendation 74: use high-order functions/123
Recommendation 75: function kerihua/125
Recommendation 76: Pay attention to function throttling/126
Suggestion 77: recommended scope-safe constructor/127
Recommendation 78: correctly understand the execution context and scope chain/129
Chapter 2 object-oriented programming/4th
Recommendation 79: Prototype mechanism analysis with reference to Object Construction System/133
Suggestion 80: Use the prototype properly/137
Recommendation 81: The prototype domain chain is not a scope chain/140
Recommendation 82: do not directly retrieve the object property value/142
Recommendation 83: Use prototype Delegation/143
Recommendation 84: Prevent prototype reflection/144
Recommendation 85: process the scope/145 of the object with caution.
Recommendation 86: use object-oriented simulated Inheritance/149
Suggestion 87: identify the relationship between this and function calling/152
Suggestion 88: this is a dynamic pointer, not a static reference/153
Recommendation 89: apply this/157 correctly
Recommendation 90: policy for preventing this misuse/161
Recommendation 91: We recommend that you use the constructor prototype to define classes/164
Recommendation 92: Prototype Inheritance/166 is not recommended.
Recommendation 93: class inheritance is recommended/168
Recommendation 94: encapsulation class inheritance/171
Suggestion 95: Use instance inheritance with caution/172
Recommendation 96: Avoid using copy Inheritance/174
Recommendation 97: Hybrid Inheritance/175 is recommended.
Recommendation 98: Compare JavaScript polymorphism, overload, and overwrite/176
Recommendation 99: actively encapsulate classes/179
Recommendation 100: exercise caution when using static members of a class/181
Recommendation 101: comparison class construction and analysis features/183
Suggestion 102: Use the Meta class/186
Suggestion 103: Use the metadata class/188
Suggestion 104: use pseudo classes with caution/190
Recommendation 105: compare two Singleton modes/192
Chapter 2 Dom programming/5th
Suggestion 106: Check the browser's Dom support level/195
Suggestion 107: Clear HTML Dom loading process/198
Suggestion 108: exercise caution when accessing DOM/200
Recommendation 109: Compare innerhtml with standard DOM methods/200
Suggestion 110: Alert Against the Space bug in document traversal/202
Recommendation 111: it is better to clone a node than to create a node/203
Suggestion 112: exercise caution when using HTML collections/204
Suggestion 113: Use a local variable to access the collection element/206
Recommendation 114: Use nextsibling to capture Dom/207
Recommendation 115: Implement Dom prototype Inheritance Mechanism/207
Suggestion 116: CSS selector/210 is recommended
Recommendation 117: reduce Dom re-painting and re-layout times/211
Suggestion 118: Use the DOM tree structure to host events/216
Suggestion 119: Use a timer to optimize the UI queue/217
Recommendation 120: Use a timer to separate tasks/220
Suggestion 121: Use a timer to run code/221
Recommendation 122: Recommended webpage worker thread/222
Chapter 2 client programming/6th
Recommendation 123: Compare IE and W3C event streams/226
Suggestion 124: design the mouse drag and drop solution/229
Suggestion 125: design the mouse pointer positioning scheme/231
Suggestion 126: carefully locate the mouse pointer in the element/233
Recommendation 127: properly use the domcontentloaded event/234
Recommendation 128: beforeunload event/236 is recommended
Suggestion 129: Custom Event/236
Suggestion 130: extract the element size from the CSS style sheet/238
Suggestion 131: Use offsetwidth and offsetheight/241 with caution
Suggestion 132: Calculate the correct area size/244
Suggestion 133: Calculate the scroll area size with caution/247
134 recommended: avoid calculating the window size/248
Suggestion 135: Obtain the absolute position correctly/249
Suggestion 136: Obtain the relative position correctly/251
Chapter 5 Data Interaction and storage/7th
Suggestion 137: Use a hidden framework to Implement Asynchronous Communication/254
138 recommended: Use IFRAME for asynchronous communication/257
Suggestion 139: use script for asynchronous communication/259
Suggestion 140: Correct Understanding of jsonp asynchronous communication protocol/264
Recommendation 141: Common server request methods/267
Recommendation 142: Common server data sending methods/271
Recommendation 143: Avoid communication in XML format/273
Suggestion 144: JSON format is recommended for communication/275
Suggestion 145: Use HTML format for communication with caution/278
Suggestion 146: use custom format for communication/279
Recommendation 147: Ajax performance wizard/280
Recommendation 148: use local data storage/281
Suggestion 149: Be cautious with Dom-based cross-origin intrusion/283
Recommendation 150: Best practices for optimizing Ajax development/286
Recommendation 151: data storage should consider access speed/290
Suggestion 152: use local variables to store data/291
Suggestion 153: Be alert to manual changes to the scope chain/293
Suggestion 154: use dynamic scope with caution/294
Suggestion 155: Careful closure causes memory leakage/295
Recommendation 156: flexible use of cookies to store persistent information/296
Suggestion 157: We recommend that You encapsulate the cookie application interface/298
Chapter 2 JavaScript Engine and compatibility/8th
Recommendation 158: Kernel resolution of mainstream browsers/300
Recommendation 159: check based on browser features/302
Recommendation 160: focus on differences between various engines on ecmascript V3/305
Recommendation 161: Add ecmascript V3 to various engines/316
Recommendation 162: focus on differences between various engines on Event parsing/327
Recommendation 163: focus on the differences of various engines on Dom parsing/330
Recommendation 164: focus on the differences between various engines on CSS rendering/335
Chapter 2 JavaScript programming specifications and applications/9th
Suggestion 165: Do not confuse JavaScript with Browser/339
Suggestion 166: master the Javascript pre-compilation process/340
Suggestion 167: accurately analyze the Javascript execution sequence/344
Recommendation 168: avoid secondary evaluation/350
Suggestion 169: recommended quantity/351
Recommendation 170: Do not repeat Javascript Engines/351
Recommendation 171: Use a bitwise operator to perform logical operations/353
Suggestion 172: Native method is recommended/355
Suggestion 173: Write a non-blocking Javascript script/356
Suggestion 174: delay script execution/358
Recommendation 175: xhr Script Injection/362
Recommendation 176: We recommend that you optimize the non-blocking mode/362
Recommendation 177: Avoid access in scope/363
Recommendation 178: Recommended JavaScript Performance Tuning/365
Recommendation 179: reduce the repaint and reflow/368 in Dom operations
Recommendation 180: Improve Dom access efficiency/370
Recommendation 181: use setTimeout to implement the Working thread/372
Recommendation 182: Use web worker/375
Suggestion 183: avoid Memory leakage/377
Recommendation 184: Use SVG to create dynamic images/380
Suggestion 185: reduce access to object members/385
Recommendation 186: 100 ms user experience/388
Suggestion 187: use interfaces to solve Javascript file Conflicts/390
Suggestion 188: Avoid JavaScript conflicts with CSS/392

Source of this book: China Interactive publishing network

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.