# effective-javascript **Repository Path**: mayyingzi/effective-javascript ## Basic Information - **Project Name**: effective-javascript - **Description**: To be, or not to be, that is a question! :joy: 万剑归宗的无名和独霸天下的雄霸 - **Primary Language**: JavaScript - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 1 - **Created**: 2021-05-11 - **Last Updated**: 2021-05-11 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README ## Effective JavaScript **只是看看的话,对你的帮助没有多大,你需要的是一条一条的实践;理论上,实践过下面的68个项目之后,你的JS能力应该有一个质的飞跃** + [x] Chapter 1 **Accustoming Yourself to JavaScript** - [x] [Item 1: **知道你正在使用的JavaScript模式** (Know Which JavaScript You Are Using)](chapter-1/know-which-javascript-you-are-using.md) - [x] [Item 2: **注意JavaScript的浮点数** (Understand JavaScript’s Floating-Point Numbers)](chapter-1/understand-javascript’s-floating-point-numbers.md) - [x] [Item 3: **当心隐形的强制转换** (Beware of Implicit Coercions)](chapter-1/beware-of-implicit-coercions.md) - [x] [Item 4: **使用原始类型替代对象包裹** (Prefer Primitives to Object Wrappers)](chapter-1/prefer-primitives-to-object-wrappers.md) - [x] [Item 5: **混合类型避免使用`==`比较是否相等** (Avoid using == with Mixed Types)](chapter-1/avoid-using-not-strict-equality-with-mixed-types.md) - [x] [Item 6: **学习分号的插入机制** (Learn the Limits of Semicolon Insertion)](chapter-1/learn-the-limits-of-semicolon-insertion.md) - [x] [Item 7: **把字符串当做16位编码单元的序列** (Think of Strings As Sequences of 16-Bit Code Units)](chapter-1/think-of-strings-as-sequences-of-16-bit-code-units.md) + [x] Chapter 2 **Variable Scope** - [x] [item 8: **尽量少用全局变量** (Minimize Use of the Global Object)](chapter-2/minimize-use-of-the-global-object.md) - [x] [item 9: **始终声明局部变量** (Always Declare Local Variables)](chapter-2/always-declare-local-variables.md) - [x] [item 10: **避免使用with** (Avoid with)](chapter-2/avoid-with.md) - [x] [item 11: **熟练掌握闭包** (Get Comfortable with Closures)](chapter-2/get-comfortable-with-closures.md) - [x] [item 12: **理解变量声明提升** (Understand Variable Hoisting)](chapter-2/understand-variable-hoisting.md) - [x] [item 13: **使用立即调用的函数表达式创建新的作用域** (Use Immediately Invoked Function Expressions to Create Local Scopes)](chapter-2/use-immediately-invoked-function-expressions-to-create-local-scopes.md) - [x] [item 14: **当心命名函数表达式笨拙的作用域** (Beware of Unportable Scoping of Named Function Expressions)](chapter-2/beware-of-unportable-scoping-of-named-function-expressions.md) - [x] [item 15: **当心局部块函数声明笨拙的作用域** (Beware of Unportable Scoping of Block-Local Function Declarations)](chapter-2/beware-of-unportable-scoping-of-block-local-function-declarations.md) - [x] [item 16: **避免使用eval创建局部变量** (Avoid Creating Local Variables with eval)](chapter-2/avoid-creating-local-variables-with-eval.md) - [x] [item 17: **间接调用`eval`函数优于直接调用** (Prefer Indirect eval to Direct eval)](chapter-2/prefer-indirect-eval-to-direct-eval.md) + [x] Chapter 3 **Working with Functions** - [x] [item 18: **理解函数调用,方法调用及构造函数调用之间的不同** (Understand the Difference between Function, Method, and Constructor Calls)](chapter-3/understand-the-difference-between-function-method-and-constructor-calls.md) - [x] [item 19: **熟练掌握高阶函数** (Get Comfortable Using Higher-Order Functions)](chapter-3/get-comfortable-using-higher-order-functions.md) - [x] [item 20: **使用`call`方法自定义接受者来调用方法** (Use call to Call Methods with a Custom Receiver)](chapter-3/use-call-to-call-methods-with-a-custom-receiver.md) - [x] [item 21: **使用`apply`方法通过不同数量的参数调用函数** (Use apply to Call Functions with Different Numbers of Arguments)](chapter-3/use-apply-to-call-functions-with-different-numbers-of-arguments.md) - [x] [item 22: **使用`arguments`创建可变参数的函数** (Use arguments to Create Variadic Functions)](chapter-3/use-arguments-to-create-variadic-functions.md) - [x] [item 23: **永远不要修改`arguments`对象** (Never Modify the arguments Object)](chapter-3/never-modify-the-arguments-object.md) - [x] [item 24: **使用变量保存`arguments`的引用** (Use a Variable to Save a Reference to arguments)](chapter-3/use-a-variable-to-save-a-reference-to-arguments.md) - [x] [item 25: **使用`bind`方法提取具有确定接受者的方法** (Use bind to Extract Methods with a Fixed Receiver)](chapter-3/use-bind-to-extract-methods-with-a-fixed-receiver.md) - [x] [item 26: **使用`bind`方法实现函数的柯里化** (Use bind to Curry Functions)](chapter-3/use-bind-to-curry-functions.md) - [x] [item 27: **使用闭包而不是字符串来封装代码** (Prefer Closures to Strings for Encapsulating Code)](chapter-3/prefer-closures-to-strings-for-encapsulating-code.md) - [x] [item 28: **不要信赖函数的对象的`toString`方法** (Avoid Relying on the toString Method of Functions)](chapter-3/avoid-relying-on-the-toString-method-of-functions.md) - [x] [item 29: **避免使用非标准的栈检查属性** (Avoid Nonstandard Stack Inspection Properties)](chapter-3/avoid-nonstandard-stack-inspection-properties.md) + [x] Chapter 4 **Objects and Prototypes** - [x] [item 30: **理解`prototype`,`getPrototypeOf`和`__proto__`之间的不同** (Understand the Difference between prototype, getPrototypeOf, and __proto__)](chapter-4/understand-the-difference-between-prototype-getPrototypeOf-and-__proto__.md) - [x] [item 31: **使用`Object.getPropertyOf`函数而不要使用`__proto__`属性** (Prefer Object.getPrototypeOf to __proto__)](chapter-4/prefer-object.getPrototypeOf-to-__proto__.md) - [x] [item 32: **始终不要修改`__proto__`属性** (Never Modify __proto__)](chapter-4/never-modify-__proto__.md) - [x] [item 33: **使构造函数与操作符`new`无关** (Make Your Constructors new-Agnostic)](chapter-4/make-your-constructors-new-agnostic.md) - [x] [item 34: **在原型中存储方法** (Store Methods on Prototypes)](chapter-4/store-methods-on-prototypes.md) - [x] [item 35: **使用闭包存储私有数据** (Use Closures to Store Private Data)](chapter-4/use-closures-to-store-private-data.md) - [x] [item 36: **只将实例状态存储在实例对象中** (Store Instance State Only on Instance Objects)](chapter-4/store-instance-state-only-on-instance-objects.md) - [x] [item 37: **认识到`this`变量的隐式绑定问题** (Recognize the Implicit Binding of this)](chapter-4/recognize-the-implicit-binding-of-this.md) - [x] [item 38: **在子类的构造函数中调用父类的构造函数** (Call Superclass Constructors from Subclass Constructors)](chapter-4/call-superclass-constructors-from-subclass-constructors.md) - [x] [item 39: **不要重用父类的属性名** (Never Reuse Superclass Property Names)](chapter-4/never-reuse-superclass-property-names.md) - [x] [item 40: **避免继承标准类** (Avoid Inheriting from Standard Classes)](chapter-4/avoid-inheriting-from-standard-classes.md) - [x] [item 41: **将原形视为实现的细节** (Treat Prototypes As an Implementation Detail)](chapter-4/treat-prototypes-as-an-implementation-detail.md) - [x] [item 42: **避免使用轻率的猴子补丁** (Avoid Reckless Monkey-Patching)](chapter-4/avoid-reckless-monkey-patching.md) + [x] Chapter 5 **Arrays and Dictionaries** - [x] [item 43: **使用`Object`的直接实例构造轻量级的字典** (Build Lightweight Dictionaries from Direct Instances of Object)](chapter-5/build-lightweight-dictionaries-from-direct-instances-of-object.md) - [x] [item 44: **使用`null`原型以防止原型污染** (Use null Prototypes to Prevent Prototype Pollution)](chapter-5/use-null-prototypes-to-prevent-prototype-pollution.md) - [x] [item 45: **使用`hasOwnProperty`方法以避免原型污染** (Use hasOwnProperty to Protect Against Prototype Pollution)](chapter-5/use-hasOwnProperty-to-protect-against-prototype-pollution.md) - [x] [item 46: **使用数组而不要使用字典来存储有序集合** (Prefer Arrays to Dictionaries for Ordered Collections)](chapter-5/prefer-arrays-to-dictionaries-for-ordered-collections.md) - [x] [item 47: **绝不要在`Object.prototype`中增加可枚举的属性** (Never Add Enumerable Properties to Object.prototype)](chapter-5/never-add-enumerable-properties-to-Object.prototype.md) - [x] [item 48: **(非常值得自己实践一下)避免在枚举期间修改对象** (Avoid Modifying an Object during Enumeration)](chapter-5/avoid-modifying-an-Object-during-enumeration.md) - [x] [item 49: **数组迭代要优先使用`for`循环而不是`for...in`循环** (Prefer for Loops to for...in Loops for Array Iteration)](chapter-5/prefer-for-loops-to-for-in-loops-for-array-iteration.md) - [x] [item 50: **迭代方法优于循环** (Prefer Iteration Methods to Loops)](chapter-5/prefer-iteration-methods-to-loops.md) - [x] [item 51: **在类数组对象上复用通用的数组方法** (Reuse Generic Array Methods on Array-Like Objects)](chapter-5/reuse-generic-array-methods-on-array-like-Objects.md) - [x] [item 52: **数组字面量优于数组构造函数** (Prefer Array Literals to the Array Constructor)](chapter-5/prefer-array-literals-to-the-array-constructor.md) + [x] Chapter 6 **Library and API Design** - [x] [item 53: **保持一致的约定** (Maintain Consistent Conventions)](chapter-6/maintain-consistent-conventions.md) - [x] [item 54: **将`undefined`看做"没有值"** (Treat undefined As “No Value”)](chapter-6/treat-undefined-as-no-value.md) - [x] [item 55: **接收关键字参数的选项对象** (Accept Options Objects for Keyword Arguments)](chapter-6/accept-options-objects-for-keyword-arguments.md) - [x] [item 56: **避免不必要的状态** (Avoid Unnecessary State)](chapter-6/avoid-unnecessary-state.md) - [x] [item 57: **使用结构类型设计灵活的接口** (Use Structural Typing for Flexible Interfaces)](chapter-6/use-structural-typing-for-flexible-interfaces.md) - [x] [item 58: **区分数组对象和类数组对象** (Distinguish between Array and Array-Like)](chapter-6/distinguish-between-array-and-array-like.md) - [x] [item 59: **避免过度的强制转换** (Avoid Excessive Coercion)](chapter-6/avoid-excessive-coercion.md) - [x] [item 60: **支持方法链** (Support Method Chaining)](chapter-6/support-method-chaining.md) + [x] Chapter 7 **Concurrency** - [x] [item 61: **不要阻塞I/O事件队列** (Don’t Block the Event Queue on I/O)](chapter-7/do-not-block-the-event-queue-on-io.md) - [x] [item 62: **(已经不推荐使用)在异步序列中使用嵌套或命名的回调函数** (Use Nested or Named Callbacks for Asynchronous Sequencing)](chapter-7/use-nested-or-named-callbacks-for-asynchronous-sequencing.md) - [x] [item 63: **当心丢弃错误** (Be Aware of Dropped Errors)](chapter-7/be-aware-of-dropped-errors.md) - [x] [item 64: **对异步的循环使用递归** (Use Recursion for Asynchronous Loops)](chapter-7/use-recursion-for-asynchronous-loops.md) - [x] [item 65: **不要在计算时阻塞事件队列** (Don’t Block the Event Queue on Computation)](chapter-7/do-not-block-the-event-queue-on-computation.md) - [x] [item 66: **使用计数器来执行并行操作** (Use a Counter to Perform Concurrent Operations)](chapter-7/use-a-counter-to-perform-concurrent-operations.md) - [x] [item 67: **绝不要同步地调用异步的回调函数** (Never Call Asynchronous Callbacks Synchronously)](chapter-7/never-call-asynchronous-callbacks-synchronously.md) - [x] [item 68: **(非常值得自己实践)使用`promise`模式清洁异步逻辑** (Use Promises for Cleaner Asynchronous Logic)](chapter-7/) ------ + 关于电子书: [英语原版][1] [中文版][2] + 官方的代码在这里,不过是不完整的,只包含第一章和第二章的代码。[code](https://github.com/effectivejs/code) + 第三章至第七章的例子跟书上的不太一样,我简化了部分,演示了重点。 [1]:http://o8qt8c0nf.bkt.clouddn.com/%5BEffective%20JavaScript%2068%20Specific%20Ways%20to%20Harness%20the%20Power%20of%20JavaScript%20%28Effective%20Software%20Development%20Series%29%20by%20David%20Herman%20-%202013%5D.pdf [2]:http://o8qt8c0nf.bkt.clouddn.com/Effective%20JavaScript%EF%BC%9A%E7%BC%96%E5%86%99%E9%AB%98%E8%B4%A8%E9%87%8FJavaScript%E4%BB%A3%E7%A0%81%E7%9A%8468%E4%B8%AA%E6%9C%89%E6%95%88%E6%96%B9%E6%B3%95%EF%BC%88%E5%B8%A6%E4%B9%A6%E7%AD%BE%E4%B8%AD%E6%96%87%E6%89%AB%E6%8F%8F%E7%89%88%EF%BC%89.pdf