From 594f096445106508c528f906c587131779a0921a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BD=95=E6=96=87=E6=9E=97?= <3292400833@qq.com> Date: Sat, 11 Aug 2018 15:56:26 +0800 Subject: [PATCH] fix the '[Object Type]' in "JS Type" --- JS/JS-br.md | 2 +- JS/JS-ch.md | 2 +- JS/JS-en.md | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/JS/JS-br.md b/JS/JS-br.md index e4ff55f5..a047a7bc 100644 --- a/JS/JS-br.md +++ b/JS/JS-br.md @@ -163,7 +163,7 @@ typeof null // 'object' Why does this happen? Because the initial version of JS was based on 32-bit systems, which stored type information of variables in the lower bits for performance considerations. Those start with `000` are objects, and all the bits of `null` are zero, so it is erroneously treated as an object. Although the current code of checking internal types has changed, this bug has been passed down. -We can use `Object.prototype.toString.call(xx)` if we want to get the correct data type of a variable, and then we can get a string like `[Object Type]`: +We can use `Object.prototype.toString.call(xx)` if we want to get the correct data type of a variable, and then we can get a string like `[object Type]`: ```js let a diff --git a/JS/JS-ch.md b/JS/JS-ch.md index fa90980a..a14dc4df 100644 --- a/JS/JS-ch.md +++ b/JS/JS-ch.md @@ -96,7 +96,7 @@ typeof null // 'object' PS:为什么会出现这种情况呢?因为在 JS 的最初版本中,使用的是 32 位系统,为了性能考虑使用低位存储了变量的类型信息,`000` 开头代表是对象,然而 `null` 表示为全零,所以将它错误的判断为 `object` 。虽然现在的内部类型判断代码已经改变了,但是对于这个 Bug 却是一直流传下来。 -如果我们想获得一个变量的正确类型,可以通过 `Object.prototype.toString.call(xx)`。这样我们就可以获得类似 `[Object Type]` 的字符串。 +如果我们想获得一个变量的正确类型,可以通过 `Object.prototype.toString.call(xx)`。这样我们就可以获得类似 `[object Type]` 的字符串。 ```js let a diff --git a/JS/JS-en.md b/JS/JS-en.md index fcd3b9eb..6084ee29 100644 --- a/JS/JS-en.md +++ b/JS/JS-en.md @@ -163,7 +163,7 @@ typeof null // 'object' Why does this happen? Because the initial version of JS was based on 32-bit systems, which stored type information of variables in the lower bits for performance considerations. Those start with `000` are objects, and all the bits of `null` are zero, so it is erroneously treated as an object. Although the current code of checking internal types has changed, this bug has been passed down. -We can use `Object.prototype.toString.call(xx)` if we want to get the correct data type of a variable, and then we can get a string like `[Object Type]`: +We can use `Object.prototype.toString.call(xx)` if we want to get the correct data type of a variable, and then we can get a string like `[object Type]`: ```js let a