@@ -544,7 +544,7 @@ function objectConstant(obj) {
544544 : this )
545545
546546// 方法二
547- const getGlobal = function () {
547+ function getGlobal () {
548548 if (typeof self !== ' undefined' ) {
549549 return self
550550 }
@@ -2315,7 +2315,7 @@ ES6 对这个属性的行为做出了一些修改,如果将一个匿名函数
23152315
23162316``` js
23172317// 匿名函数
2318- const f = function () {
2318+ function f () {
23192319}
23202320
23212321// ES5
@@ -2328,7 +2328,7 @@ f.name // "f"
23282328如果将一个具名函数赋值给一个变量,则 ES5 和 ES6 的name属性都返回这个具名函数原本的名字。
23292329
23302330``` js
2331- const bar = function test () {
2331+ function bar () {
23322332}
23332333
23342334// ES5
@@ -3094,9 +3094,9 @@ Array.of(3).length // 1
30943094弥补数组构造函数` Array() ` 的不足。因为参数个数的不同,会导致` Array() ` 的行为有差异。
30953095
30963096``` js
3097- Array () // []
3098- Array ( 3 ) // [, , ,]
3099- Array (3 , 11 , 8 ) // [3, 11, 8]
3097+ new Array () // []
3098+ Array . from ({ length : 3 } ) // [, , ,]
3099+ new Array (3 , 11 , 8 ) // [3, 11, 8]
31003100```
31013101
31023102` Array() ` 方法没有参数、一个参数、三个参数时,返回的结果都不一样。
@@ -3430,7 +3430,7 @@ arr.flatMap(function callback(currentValue[, index[, array]]) {
34303430
34313431``` js
34323432// 返回具有 3 个空位的数组。
3433- Array ( 3 ) // [, , ,]
3433+ Array . from ({ length : 3 } ) // [, , ,]
34343434```
34353435
34363436空位不是` undefined ` ,一个位置的值等于` undefined ` ,依然是有值的。** 空位是没有任何值** ,in运算符可以说明这一点。
@@ -3833,7 +3833,7 @@ descriptor.set.name // "set foo"
38333833``` js
38343834(new Function ()).name // "anonymous"
38353835
3836- const doSomething = function () {
3836+ function doSomething () {
38373837 // ...
38383838}
38393839doSomething .bind ().name // "bound doSomething"
@@ -4328,9 +4328,9 @@ console.log(obj) // { "0": "a", "1": "b", "2": "c" }
43284328只有字符串合入目标对象(以字符数组的形式),数值和布尔值都会被忽略。**因为只有字符串的包装对象,会产生可枚举属性。**
43294329
43304330` ` ` js
4331- Object (true ) // {[[PrimitiveValue]]: true}
4332- Object (10 ) // {[[PrimitiveValue]]: 10}
4333- Object (' abc' ) // {0: "a", 1: "b", 2: "c", length: 3, [[PrimitiveValue]]: "abc"}
4331+ new Object (true ) // {[[PrimitiveValue]]: true}
4332+ new Object (10 ) // {[[PrimitiveValue]]: 10}
4333+ new Object (' abc' ) // {0: "a", 1: "b", 2: "c", length: 3, [[PrimitiveValue]]: "abc"}
43344334` ` `
43354335
43364336` 布尔值` 、` 数值` 、` 字符串` 分别转成对应的包装对象,可以看到它们的原始值都在包装对象的内部属性` [[PrimitiveValue]]`
@@ -4606,7 +4606,7 @@ obj.method = function () {
46064606` ` ` js
46074607Object .defineProperty (Object .prototype , ' __proto__' , {
46084608 get () {
4609- const _thisObj = Object (this )
4609+ const _thisObj = new Object (this )
46104610 return Object .getPrototypeOf (_thisObj)
46114611 },
46124612 set (proto ) {
0 commit comments