diff --git a/README.md b/README.md index eb6a241..4db14b8 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ + [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 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) @@ -97,4 +97,4 @@ - \ No newline at end of file + diff --git a/chapter-1/beware-of-implicit-coercions.md b/chapter-1/beware-of-implicit-coercions.md index 81231c6..ffb9d66 100644 --- a/chapter-1/beware-of-implicit-coercions.md +++ b/chapter-1/beware-of-implicit-coercions.md @@ -1,4 +1,4 @@ -### 当心隐形的强制转换 +### 当心隐式的强制转换 ```javascript console.log(3 + true); // 4 @@ -91,4 +91,4 @@ console.log(point()); // { x: 1, y: 1 } + `+`号运算符会根据它的参数类型来决定是做加法还是字符串的拼接。 + `Object`通过它的`toString`方法被强制转换为字符串,通过它的`valueOf`方法被强制转换为数字。 + 带有`valueOf`方法的`Object`应该实现一个`toString`方法,这个`toString`方法返回的字符串就是那个`valueOf`返回的数字的字符串表示形式。 -+ 判断一个值是否是未定义的应该使用`typeof`或者比较的方法,而不是根据这个值表现是`true`或者`false`来判断。 \ No newline at end of file ++ 判断一个值是否是未定义的应该使用`typeof`或者比较的方法,而不是根据这个值表现是`true`或者`false`来判断。