Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
1755 commits
Select commit Hold shift + click to select a range
a6e8a40
refactor: add tencent.txt
ruanyf Feb 23, 2020
b0b10a3
refactor: add tencent.txt
ruanyf Feb 23, 2020
717f4e4
docs: fix #952
ruanyf Feb 23, 2020
296159a
修正一处小地方
EggOxygen Feb 25, 2020
57701fc
docs(class): fix typo
ruanyf Feb 27, 2020
2e1c107
Merge pull request #954 from EggOxygen/patch-1
ruanyf Feb 27, 2020
b4ec056
fix: 使语句更通顺
anhongpeng Feb 29, 2020
518f311
refactor: update disqus url to HTTPS
ruanyf Mar 3, 2020
6800796
docs(async): 如何处理数组的异步操作
ruanyf Mar 3, 2020
3405f13
Merge pull request #955 from AnHongpeng/gh-pages
ruanyf Mar 4, 2020
6069e3f
使用core-js替代过时的@babel/polyfill
Mookiepiece Mar 7, 2020
130cdee
Merge pull request #958 from Mookiepiece/master
ruanyf Mar 10, 2020
428a748
docs(intro): delete Babel API #958
ruanyf Mar 10, 2020
0f65697
perf: remove unnecessary closure
MingCheHarden Mar 13, 2020
21e3cfb
Merge pull request #960 from yaoguoli/patch-1
ruanyf Mar 16, 2020
e692306
fix: arraybuffer.md add `new`
hou-pu Mar 18, 2020
74acd64
Merge pull request #961 from wangzongxu/patch-1
ruanyf Mar 18, 2020
f18bd46
修复表述错误
linmii Mar 21, 2020
2061ad9
修正 `exec()` 拼写
kidonng Mar 22, 2020
f330662
Merge pull request #964 from kidonng/patch-1
ruanyf Mar 23, 2020
f71a2ce
docs(number): fix #965
ruanyf Mar 23, 2020
491f6f0
Merge pull request #962 from linmii/patch-1
ruanyf Mar 23, 2020
cd0310c
docs(object): 修改扩展运算符自动执行取值函数 get 的例子
ruanyf Mar 23, 2020
31ab7b1
去除多余文字
linmii Mar 24, 2020
fe72377
refactor: edit sponsor banner
ruanyf Mar 24, 2020
0068aa5
refactor: edit sponsor banner
ruanyf Mar 25, 2020
f0b8e22
Merge pull request #967 from linmii/patch-2
ruanyf Mar 26, 2020
8b4db43
docs: edit object-methods
ruanyf Mar 30, 2020
7332021
统一“抽象操作的运行流程”的描述
baooab Mar 31, 2020
09d2e0b
Merge pull request #970 from baooab/patch-5
ruanyf Apr 1, 2020
03c9e34
docs(module): update es2020
ruanyf Apr 3, 2020
0849a77
Merge branch 'gh-pages' of github.com:ruanyf/es6tutorial into gh-pages
ruanyf Apr 3, 2020
ac50325
docs: edit Promise
ruanyf Apr 6, 2020
1474f82
fix(proposals): shell exec style
waitingsong Apr 7, 2020
7076dd5
docs(math): fix #973
ruanyf Apr 9, 2020
38963f7
Merge pull request #971 from waitingsong/shell-exec
ruanyf Apr 9, 2020
c3dd90d
refactor: edit ditto/support
ruanyf Apr 13, 2020
f810124
Merge branch 'gh-pages' of github.com:ruanyf/es6tutorial into gh-pages
ruanyf Apr 13, 2020
e11dc14
Update module.md
suzhongping Apr 24, 2020
d65a547
Merge pull request #979 from suzhongping/patch-1
ruanyf Apr 25, 2020
2f908a5
完善Reflect.ownkeys()方法的描述
chenweitech May 8, 2020
6f59bc3
docs(proxy): edit defineProperty
ruanyf May 13, 2020
3832b6a
refactor: adjust support date
ruanyf May 13, 2020
18e372d
Merge pull request #982 from chenweitech/patch-1
ruanyf May 14, 2020
55cbbb8
fix: li tag click bug #984
ruanyf May 14, 2020
323e962
docs(set): fix #991
ruanyf May 31, 2020
f0a92d5
docs(regex): fixed matchall() #992
ruanyf Jun 12, 2020
0219f20
docs(object): edit 链判断运算符 ?.
ruanyf Jun 21, 2020
d59b301
docs(number): edit BigInt
ruanyf Jul 6, 2020
4425866
docs(object): edit null 判断运算符
ruanyf Jul 7, 2020
064ee65
docs(object-methods): edit Object.assign()
ruanyf Jul 7, 2020
e785137
docs(let): fix #1001
ruanyf Aug 6, 2020
9461a92
docs: edit README
ruanyf Aug 14, 2020
266199c
docs(module-loader): edit Node.js 的模块加载
ruanyf Aug 19, 2020
09accf9
docs(module-loader): fix typo
ruanyf Aug 19, 2020
7b8c063
docs(module-loader): edit 同时支持两种格式的模块
ruanyf Aug 20, 2020
a841acd
docs(module-loader): fix typo
ruanyf Aug 20, 2020
2613635
docs(module-loader): fix typo
ruanyf Aug 20, 2020
dfe3373
feat: add change theme
Aug 21, 2020
e33a668
upt: delete note
Aug 25, 2020
adb4964
docs(module-loader): fix typo
ruanyf Aug 29, 2020
dd892f8
Merge pull request #1002 from zhidaoliu/gh-pages
ruanyf Aug 29, 2020
4e14b40
docs(object): fix #1004
ruanyf Sep 1, 2020
2f76a9f
(docs): fix typo
hehe1111 Sep 9, 2020
76fc255
docs(promise): edit Promise.reject()
ruanyf Sep 10, 2020
04ff592
Merge pull request #1006 from hehe1111/patch-1
ruanyf Sep 10, 2020
d4952d6
docs(module-loader): fix typo
ruanyf Sep 10, 2020
50b25c1
Merge branch 'gh-pages' of github.com:ruanyf/es6tutorial into gh-pages
ruanyf Sep 10, 2020
6dc250f
docs(decorator): 修改函数提升时代码实际执行顺序
careteenL Sep 12, 2020
c432253
优化了 async 函数内部报错会导致 Promise 对象变为`reject`状态的例子
jacty Sep 12, 2020
f81d202
docs(proxy): fix constrct()
ruanyf Sep 15, 2020
0f1acd3
docs(iterable): fix typo
ruanyf Sep 15, 2020
841eebb
Merge pull request #1007 from careteenL/patch-1
ruanyf Sep 15, 2020
8a5b570
Merge pull request #1008 from jacty/patch-1
ruanyf Sep 15, 2020
10defdb
docs(async): fix typo
ruanyf Sep 15, 2020
9f1f925
Update proxy.md
chua1989 Sep 15, 2020
48e318b
Update proxy.md
chua1989 Sep 15, 2020
c025fc9
Merge pull request #1009 from chua1989/gh-pages
ruanyf Sep 16, 2020
746a918
docs(proxy): edit construct()
ruanyf Sep 16, 2020
6ff7cb8
docs(class): fix private property
ruanyf Sep 17, 2020
c2d1792
docs(set-map): edit WeakMap
ruanyf Sep 22, 2020
4bd4d77
docs(function/arrow fucntion): edit #150
ruanyf Oct 2, 2020
2e082a3
docs(module): fix module suffix
ruanyf Oct 23, 2020
8f852c0
docs(Atomics): Atomics.wake() rename to Atomics.notify()
ruanyf Oct 24, 2020
d1f96fe
docs(proxy): fix this #1014
ruanyf Oct 24, 2020
356b0db
docs(string): add replaceAll()
ruanyf Oct 25, 2020
492fb25
docs(string-methods): add replaceAll()
ruanyf Oct 27, 2020
2ed3a6b
docs(promise): edit Promise.any()
ruanyf Oct 31, 2020
04dddb2
docs: fix wangdoc-es6 #4
ruanyf Oct 31, 2020
861dd41
docs(arraybuffer): edit Atomics.load()
ruanyf Nov 6, 2020
f817164
docs(string-methods): edit replaceAll(), fixed #1018
ruanyf Nov 17, 2020
a326217
docs(string): fix typo
ruanyf Nov 17, 2020
ff47784
docs(style): fixed #1020
ruanyf Nov 24, 2020
584d5d9
docs(generator): edit style
ruanyf Nov 24, 2020
201eebe
docs(async): fixed #1023
ruanyf Nov 29, 2020
bc0ba76
docs(async): edit reduce()
ruanyf Nov 29, 2020
038a080
refactor: edit support banner
ruanyf Dec 2, 2020
761d107
refactor: edit support banner
ruanyf Dec 2, 2020
56d15b3
refactor: edit support banner
ruanyf Dec 3, 2020
d041893
docs(class): edit class intro
ruanyf Dec 9, 2020
cc2420e
docs(function): edit arrow function
ruanyf Dec 17, 2020
1c99572
docs(promise): fix #1028
ruanyf Dec 22, 2020
1d556be
Update promise.md
Geekhyt Dec 22, 2020
78972be
Merge pull request #1029 from Geekhyt/patch-2
ruanyf Dec 22, 2020
4309e6a
docs(regex): edit regex
ruanyf Jan 6, 2021
802ee5e
Merge branch 'gh-pages' of github.com:ruanyf/es6tutorial into gh-pages
ruanyf Jan 6, 2021
b45161a
docs(proxy): fix #1032
ruanyf Jan 22, 2021
9461630
refactor: edit support js
ruanyf Feb 5, 2021
543678f
docs(array): fix #1037
ruanyf Feb 11, 2021
ec9db66
refactor: edit support banner
ruanyf Feb 20, 2021
631a66e
refactor: edit support banner
ruanyf Feb 20, 2021
3929f4f
refactor: edit support banner
ruanyf Feb 23, 2021
e9fd28b
fix: remove 'else'
roc-an Apr 18, 2021
d09058f
fix: 为输出补充示例
roc-an Apr 20, 2021
d39c55d
Merge pull request #1045 from roc-an/patch-2
ruanyf Apr 23, 2021
95f57f8
Merge pull request #1044 from roc-an/patch-1
ruanyf Apr 23, 2021
fa03d29
fix: 强迫症犯了想去掉多余空格好看一些
roc-an Apr 24, 2021
59146b4
docs(proxy): fix set return value #1047
ruanyf Apr 26, 2021
0163114
Merge pull request #1048 from roc-an/patch-3
ruanyf Apr 26, 2021
85b8174
docs(set-map): 改进 WeakSet 和 WeakMap 文档
codeudan May 8, 2021
71af30d
docs(function): fixed 箭头函数的this #1050
ruanyf May 11, 2021
e6b0210
Merge pull request #1052 from codeudan/gh-pages
ruanyf May 12, 2021
ee1b51e
docs(set-map): edit text
ruanyf May 12, 2021
d41bf83
docs(function): 调整不合适的函数描述
codeudan May 14, 2021
53cb4d3
docs: 修正已知的 this 术语错误
codeudan May 15, 2021
4f2353a
Merge pull request #1054 from codeudan/gh-pages
ruanyf May 18, 2021
0503136
Merge pull request #1055 from codeudan/fix/this
ruanyf May 18, 2021
89370af
docs(class): 添加 in 运算符
ruanyf May 24, 2021
8e236cb
refactor: edit support banner
ruanyf Jun 2, 2021
fdac6cc
docs: add ES2021
ruanyf Jul 10, 2021
9181f78
refactor: update chapters
ruanyf Jul 10, 2021
145e840
Update async.md
yonghui-wang Jul 14, 2021
2139df3
Merge pull request #1063 from yonghui-wang/patch-2
ruanyf Jul 14, 2021
6a972df
docs(operator): fix WeakRef typo
ruanyf Jul 14, 2021
9d51292
Update let.md
wgm7512 Jul 22, 2021
864c2c0
docs(proposals): JSON 模块
ruanyf Jul 22, 2021
12ce67f
Merge pull request #1064 from ThroughTheNight/patch-1
ruanyf Jul 22, 2021
4ead6a0
docs(class): fix typo #1065
ruanyf Jul 27, 2021
1f57596
一处笔误
MrCare Jul 31, 2021
5eb76ed
Merge pull request #1066 from MrCare/patch-1
ruanyf Aug 1, 2021
9cf2cca
refactor: edit support banner
ruanyf Aug 4, 2021
562c688
Update function.md
wgm7512 Aug 6, 2021
0549983
fix: BigInt 不是构造函数
roc-an Aug 6, 2021
a802e37
Update operator.md
newbeman Aug 7, 2021
de8fad9
docs(promise): edit Promise.allSettled()
ruanyf Aug 9, 2021
25f95e0
Merge pull request #1071 from ThroughTheNight/patch-2
ruanyf Aug 9, 2021
f56ca0a
Merge pull request #1072 from roc-an/patch-4
ruanyf Aug 9, 2021
4d9b22c
Merge pull request #1073 from newbeman/patch-1
ruanyf Aug 9, 2021
47dec55
docs(class): 加入 static block
ruanyf Sep 2, 2021
d50868c
refactor: edit support banner
ruanyf Sep 2, 2021
84dba56
docs(style): fixed #1076
ruanyf Sep 8, 2021
248b51a
fix typo: 或 -> 会
imba-tjd Sep 8, 2021
daa455f
use https for some links
imba-tjd Sep 9, 2021
c43e5ca
Merge pull request #1077 from imba-tjd/patch-1
ruanyf Sep 9, 2021
9b210c0
Merge pull request #1078 from imba-tjd/patch-2
ruanyf Sep 9, 2021
9388b33
Update intro.md
Lohoyo Sep 17, 2021
a687c39
Merge pull request #1081 from Lohoyo/patch-1
ruanyf Sep 17, 2021
1fdd34e
docs(object): add AggregateError
ruanyf Sep 19, 2021
e17a581
docs(object): edit AggregateError
ruanyf Sep 19, 2021
180c700
docs(style): edit module style suggestion
ruanyf Oct 4, 2021
de76869
docs(string): fixed #1086
ruanyf Oct 19, 2021
5b57360
Update function.md
Lohoyo Oct 19, 2021
cee42e6
Merge pull request #1088 from Lohoyo/patch-2
ruanyf Oct 21, 2021
728b545
Add script suffix to prevent error
vinzid Oct 31, 2021
a82ed10
Merge pull request #1089 from vinzid/patch-1
ruanyf Nov 1, 2021
1a0eaa5
docs(iterator): fixed #1093
ruanyf Nov 13, 2021
79e871c
docs(array): add at()
ruanyf Nov 14, 2021
2215773
Update string-methods.md
ConradZhangcong Nov 16, 2021
c039b6f
Merge pull request #1094 from ConradZhangcong/gh-pages
ruanyf Nov 22, 2021
74de293
Update array.md
ConradZhangcong Nov 23, 2021
f4030e1
Merge pull request #1097 from ConradZhangcong/gh-pages
ruanyf Nov 23, 2021
a066b9a
docs(module-loader): fix typo
ruanyf Nov 23, 2021
a0265ef
refactor: adjust support code
ruanyf Nov 30, 2021
4781407
refactor: adjust support code
ruanyf Nov 30, 2021
664f685
docs(class): fixed #1099
ruanyf Dec 2, 2021
fd3eb89
docs(proxy): fixed #1100
ruanyf Dec 2, 2021
d9ec0db
refact: edit support script
ruanyf Dec 29, 2021
cddf4b8
refactor: edit support banner
ruanyf Dec 31, 2021
255eedb
docs(reg): edit Unicode 属性类
ruanyf Jan 6, 2022
7fa7ee1
docs(class-extends): edit text
ruanyf Jan 24, 2022
e064886
Update class-extends.md
liuxuan1-1 Feb 5, 2022
b270280
Merge pull request #1108 from liuxuan1-1/patch-2
ruanyf Feb 5, 2022
b2a122e
docs(symbol): fixed #1107
ruanyf Feb 6, 2022
bcfe5ee
refactor: add support banner
ruanyf Feb 7, 2022
8d81fef
refactor: add support banner
ruanyf Feb 7, 2022
9218ba8
refactor: add support banner
ruanyf Feb 8, 2022
ce7fd81
Update object.md
5unnyWind Mar 2, 2022
1fad026
Merge pull request #1110 from 5unnyWind/patch-1
ruanyf Mar 8, 2022
8a214a6
docs(array): edit Array.from()
ruanyf Mar 31, 2022
e856f9e
docs(function): edit 函数参数的解构赋值
ruanyf Apr 9, 2022
95e2e79
docs(object): edit 对象的扩展运算符
ruanyf Apr 9, 2022
ef70334
docs(module): edit import()
ruanyf May 29, 2022
8b9f192
docs(promise): edit Promise.any()
Mookiepiece Jun 4, 2022
b5fa350
Merge pull request #1118 from Mookiepiece/gh-pages
ruanyf Jun 7, 2022
e0772de
docs(promise): edit AggregateError
ruanyf Jun 7, 2022
a837d8f
docs: update ES2022
ruanyf Jun 25, 2022
6880b36
docs(class): fix typo
ruanyf Jun 25, 2022
41970f7
docs: update latest proposals
ruanyf Jun 26, 2022
fbd7faf
docs(decorator): add stage 3 proposal content
ruanyf Jun 27, 2022
f6bb1b9
docs(decorator): edit editor notes
ruanyf Jun 27, 2022
f45f032
docs(regex): fix es2022 indices
xt1995726 Jun 30, 2022
d4d888e
typo: match -> match()
xt1995726 Jun 30, 2022
a090a27
docs(async): fix typo
condorheroblog Jul 1, 2022
aab3314
Merge pull request #1121 from xt1995726/gh-pages
ruanyf Jul 6, 2022
a0c47d5
docs(regex): edit d 修饰符
ruanyf Jul 6, 2022
7d22df8
Merge pull request #1122 from condorheroblog/patch-1
ruanyf Jul 6, 2022
7d030c6
docs(async): edit top-level await
ruanyf Jul 6, 2022
4c0201c
docs(class): fixed #1125 private class field
ruanyf Jul 13, 2022
9348fd2
refactor: edit support banner
ruanyf Jul 23, 2022
010de73
docs(set-map): fix typo
nicong622 Jul 24, 2022
829920e
Merge pull request #1128 from nicong622/patch-1
ruanyf Jul 28, 2022
6bf9155
refactor: edit support banner
ruanyf Jul 31, 2022
686fcff
refactor: edit support banner
ruanyf Jul 31, 2022
21edbe4
docs(symbol): edit text
ruanyf Aug 8, 2022
2b448b6
docs(clss-extends): add inheritance of private property
ruanyf Aug 13, 2022
cf4c947
docs(proposals): edit links
ruanyf Aug 31, 2022
eba1ada
docs(proposals): edit Math.signbit()
ruanyf Aug 31, 2022
5730890
fix: line feed causes HTML rendering error view
condorheroblog Sep 1, 2022
6288fc1
Merge pull request #1135 from condorheroblog/patch-2
ruanyf Sep 1, 2022
e808d04
Update class-extends.md
w-l-l Sep 18, 2022
cded3bc
Merge pull request #1137 from w-l-l/patch-1
ruanyf Sep 18, 2022
1a8f46c
docs(class): fix typo
w-l-l Sep 20, 2022
0eaf2d8
Merge pull request #1140 from w-l-l/patch-3
ruanyf Sep 21, 2022
36b55b9
docs(class): 静态块
ruanyf Sep 21, 2022
ef5e3a2
docs(class): fix typo
ruanyf Oct 18, 2022
7f1acfe
docs(module): move import.meta from proposals to module
ruanyf Oct 23, 2022
406ba6d
docs(module): fix import.meta typo
ruanyf Oct 23, 2022
ef2f878
docs(decorator): edit text
ruanyf Oct 23, 2022
add0bba
docs(decorator): fix typo
w-l-l Dec 4, 2022
1623fdc
Merge pull request #1144 from w-l-l/patch-4
ruanyf Dec 7, 2022
90c0ea7
docs(class-extends): add new materials into super()
ruanyf Dec 23, 2022
f9ef8fd
refactor: add wwads banner
ruanyf Jan 10, 2023
c1a81dc
refactor: adjust wwads banner
ruanyf Jan 10, 2023
536ac22
refactor: adjust wwads banner
ruanyf Jan 10, 2023
010daf6
refactor: adjust wwads banner
ruanyf Jan 10, 2023
09a4657
refactor: adjust wwads banner
ruanyf Jan 10, 2023
b9c8b3d
refactor: adjust wwads banner
ruanyf Jan 10, 2023
b638fb0
refactor: adjust wwads banner
ruanyf Jan 10, 2023
9007f1f
refactor: prism添加对typescript的支持
likeke1997 Jan 16, 2023
6d244f6
Merge pull request #1145 from likeke1997/gh-pages
ruanyf Jan 19, 2023
7fc248d
Update arraybuffer.md
peterwangfeng Feb 1, 2023
07e9c15
Merge pull request #1146 from peterwangfeng/patch-1
ruanyf Feb 2, 2023
7523f55
docs(arraybuffer): update DataView methods
ruanyf Feb 2, 2023
60e128c
module-loader: remove `--experimental-conditional-exports`
islishude Feb 12, 2023
f7b84f2
Merge pull request #1148 from islishude/patch-1
ruanyf Feb 12, 2023
b20e38b
docs(set): fix delete fn
Hencky Mar 2, 2023
badabbf
Merge pull request #1149 from Hencky/gh-pages
ruanyf Mar 2, 2023
0928b9c
docs(set-map): WeakSet methods
Hencky Mar 6, 2023
b68c36d
Merge pull request #1150 from Hencky/gh-pages
ruanyf Mar 6, 2023
50e9ced
docs(operator): #! 命令
ruanyf Apr 7, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
docs: update latest proposals
  • Loading branch information
ruanyf committed Jun 26, 2022
commit 41970f7db088611b61b8c1638a6a7c27e267c1f5
117 changes: 110 additions & 7 deletions docs/array.md
Original file line number Diff line number Diff line change
Expand Up @@ -595,9 +595,9 @@ i32a.copyWithin(0, 2);
// Int32Array [4, 2, 3, 4, 5]
```

## 实例方法:find()findIndex()
## 实例方法:find()findIndex(),findLast(),findLastIndex()

数组实例的`find`方法,用于找出第一个符合条件的数组成员。它的参数是一个回调函数,所有数组成员依次执行该回调函数,直到找出第一个返回值为`true`的成员,然后返回该成员。如果没有符合条件的成员,则返回`undefined`。
数组实例的`find()`方法,用于找出第一个符合条件的数组成员。它的参数是一个回调函数,所有数组成员依次执行该回调函数,直到找出第一个返回值为`true`的成员,然后返回该成员。如果没有符合条件的成员,则返回`undefined`。

```javascript
[1, 4, -5, 10].find((n) => n < 0)
Expand All @@ -612,9 +612,9 @@ i32a.copyWithin(0, 2);
}) // 10
```

上面代码中,`find`方法的回调函数可以接受三个参数,依次为当前的值、当前的位置和原数组。
上面代码中,`find()`方法的回调函数可以接受三个参数,依次为当前的值、当前的位置和原数组。

数组实例的`findIndex`方法的用法与`find`方法非常类似,返回第一个符合条件的数组成员的位置,如果所有成员都不符合条件,则返回`-1`。
数组实例的`findIndex()`方法的用法与`find()`方法非常类似,返回第一个符合条件的数组成员的位置,如果所有成员都不符合条件,则返回`-1`。

```javascript
[1, 5, 10, 15].findIndex(function(value, index, arr) {
Expand All @@ -632,9 +632,9 @@ let person = {name: 'John', age: 20};
[10, 12, 26, 15].find(f, person); // 26
```

上面的代码中,`find`函数接收了第二个参数`person`对象,回调函数中的`this`对象指向`person`对象。
上面的代码中,`find()`函数接收了第二个参数`person`对象,回调函数中的`this`对象指向`person`对象。

另外,这两个方法都可以发现`NaN`,弥补了数组的`indexOf`方法的不足。
另外,这两个方法都可以发现`NaN`,弥补了数组的`indexOf()`方法的不足。

```javascript
[NaN].indexOf(NaN)
Expand All @@ -644,7 +644,23 @@ let person = {name: 'John', age: 20};
// 0
```

上面代码中,`indexOf`方法无法识别数组的`NaN`成员,但是`findIndex`方法可以借助`Object.is`方法做到。
上面代码中,`indexOf()`方法无法识别数组的`NaN`成员,但是`findIndex()`方法可以借助`Object.is()`方法做到。

`find()`和`findIndex()`都是从数组的0号位,依次向后检查。[ES2022](https://github.com/tc39/proposal-array-find-from-last) 新增了两个方法`findLast()`和`findLastIndex()`,从数组的最后一个成员开始,依次向前检查,其他都保持不变。

```javascript
const array = [
{ value: 1 },
{ value: 2 },
{ value: 3 },
{ value: 4 }
];

array.findLast(n => n.value % 2 === 1); // { value: 3 }
array.findLastIndex(n => n.value % 2 === 1); // 2
```

上面示例中,`findLast()`和`findLastIndex()`从数组结尾开始,寻找第一个`value`属性为奇数的成员。结果,该成员是`{ value: 3 }`,位置是2号位。

## 实例方法:fill()

Expand Down Expand Up @@ -863,6 +879,93 @@ sentence.at(-100) // undefined
sentence.at(100) // undefined
```

## 实例方法:toReversed(),toSorted(),toSpliced(),with()

很多数组的传统方法会改变原数组,比如`push()`、`pop()`、`shift()`、`unshift()`等等。数组只要调用了这些方法,它的值就变了。现在有一个[提案](https://github.com/tc39/proposal-change-array-by-copy),允许对数组进行操作时,不改变原数组,而返回一个原数组的拷贝。

这样的方法一共有四个。

- `Array.prototype.toReversed() -> Array`
- `Array.prototype.toSorted(compareFn) -> Array`
- `Array.prototype.toSpliced(start, deleteCount, ...items) -> Array`
- `Array.prototype.with(index, value) -> Array`

它们分别对应数组的原有方法。

- `toReversed()`对应`reverse()`,用来颠倒数组成员的位置。
- `toSorted()`对应`sort()`,用来对数组成员排序。
- `toSpliced()`对应`splice()`,用来在指定位置,删除指定数量的成员,并插入新成员。
- `with(index, value)`对应`splice(index, 1, value)`,用来将指定位置的成员替换为新的值。

上面是这四个新方法对应的原有方法,含义和用法完全一样,唯一不同的是不会改变原数组,而是返回原数组操作后的拷贝。

下面是示例。

```javascript
const sequence = [1, 2, 3];
sequence.toReversed() // [3, 2, 1]
sequence // [1, 2, 3]

const outOfOrder = [3, 1, 2];
outOfOrder.toSorted() // [1, 2, 3]
outOfOrder // [3, 1, 2]

const array = [1, 2, 3, 4];
array.toSpliced(1, 2, 5, 6, 7) // [1, 5, 6, 7, 4]
array // [1, 2, 3, 4]

const correctionNeeded = [1, 1, 3];
correctionNeeded.with(1, 2) // [1, 2, 3]
correctionNeeded // [1, 1, 3]
```

## 实例方法:group(),groupToMap()

数组成员分组是一个常见需求,比如 SQL 有`GROUP BY`子句和函数式编程有 MapReduce 方法。现在有一个[提案](https://github.com/tc39/proposal-array-grouping),为 JavaScript 新增了数组实例方法`group()`和`groupToMap()`,它们可以根据分组函数的运行结果,将数组成员分组。

`group()`的参数是一个分组函数,原数组的每个成员都会依次执行这个函数,确定自己是哪一个组。

```javascript
const array = [1, 2, 3, 4, 5];

array.group((num, index, array) => {
return num % 2 === 0 ? 'even': 'odd';
});
// { odd: [1, 3, 5], even: [2, 4] }
```

`group()`的分组函数可以接受三个参数,依次是数组的当前成员、该成员的位置序号、原数组(上例是`num`、`index`和`array`)。分组函数的返回值应该是字符串(或者可以自动转为字符串),以作为分组后的组名。

`group()`的返回值是一个对象,该对象的键名就是每一组的组名,即分组函数返回的每一个字符串(上例是`even`和`odd`);该对象的键值是一个数组,包括所有产生当前键名的原数组成员。

下面是另一个例子。

```javascript
[6.1, 4.2, 6.3].groupBy(Math.floor)
// { '4': [4.2], '6': [6.1, 6.3] }
```

上面示例中,`Math.floor`作为分组函数,对原数组进行分组。它的返回值原本是数值,这时会自动转为字符串,作为分组的组名。原数组的成员根据分组函数的运行结果,进入对应的组。

`group()`还可以接受一个对象,作为第二个参数。该对象会绑定分组函数(第一个参数)里面的`this`,不过如果分组函数是一个箭头函数,该对象无效,因为箭头函数内部的`this`是固化的。

`groupToMap()`的作用和用法与`group()`完全一致,唯一的区别是返回值是一个 Map 结构,而不是对象。Map 结构的键名可以是各种值,所以不管分组函数返回什么值,都会直接作为组名(Map 结构的键名),不会强制转为字符串。这对于分组函数返回值是对象的情况,尤其有用。

```javascript
const array = [1, 2, 3, 4, 5];

const odd = { odd: true };
const even = { even: true };
array.groupToMap((num, index, array) => {
return num % 2 === 0 ? even: odd;
});
// Map { {odd: true}: [1, 3, 5], {even: true}: [2, 4] }
```

上面示例返回的是一个 Map 结构,它的键名就是分组函数返回的两个对象`odd`和`even`。

总之,按照字符串分组就使用`group()`,按照对象分组就使用`groupToMap()`。

## 数组的空位

数组的空位指的是,数组的某一个位置没有任何值,比如`Array()`构造函数返回的数组都是空位。
Expand Down
35 changes: 35 additions & 0 deletions docs/regex.md
Original file line number Diff line number Diff line change
Expand Up @@ -478,6 +478,41 @@ const regexArrows = /^\p{Block=Arrows}+$/u;
regexArrows.test('←↑→↓↔↕↖↗↘↙⇏⇐⇑⇒⇓⇔⇕⇖⇗⇘⇙⇧⇩') // true
```

## v 修饰符,Unicode 属性类的运算

有时,需要向某个 Unicode 属性类添加或减少字符,即需要对属性类进行运算。现在有一个[提案](https://github.com/tc39/proposal-regexp-v-flag),增加了 Unicode 属性类的运算功能。

它提供两种形式的运算,一种是差集运算(A 集合减去 B 集合),另一种是交集运算。

```javascript
// 差集运算(A 减去 B)
[A--B]

// 交集运算(A 与 B 的交集)
[A&&B]
```

上面两种写法中,A 和 B 要么是字符类(例如`[a-z]`),要么是 Unicode 属性类(例如`\p{ASCII}`)。

而且,这种运算支持方括号之中嵌入方括号,即方括号的嵌套。

```javascript
// 方括号嵌套的例子
[A--[0-9]]
```

这种运算的前提是,正则表达式必须使用新引入的`v`修饰符。前面说过,Unicode 属性类必须搭配`u`修饰符使用,这个`v`修饰符等于代替`u`,使用了它就不必再写`u`了。

下面是一些例子。

```javascript
// 十进制字符去除 ASCII 码的0到9
[\p{Decimal_Number}--[0-9]]

// Emoji 字符去除 ASCII 码字符
[\p{Emoji}--\p{ASCII}]
```

## 具名组匹配

### 简介
Expand Down
2 changes: 2 additions & 0 deletions docs/set-map.md
Original file line number Diff line number Diff line change
Expand Up @@ -942,6 +942,8 @@ map.set(null, 2)

上面代码中,如果将数值`1`和`Symbol`值作为 WeakMap 的键名,都会报错。

不过,现在有一个[提案](https://github.com/tc39/proposal-symbols-as-weakmap-keys),允许 Symbol 值也可以作为 WeakMap 的键名。一旦纳入标准,就意味着键名存在两种可能:对象和 Symbole 值。

其次,`WeakMap`的键名所指向的对象,不计入垃圾回收机制。

`WeakMap`的设计目的在于,有时我们想在某个对象上面存放一些数据,但是这会形成对于这个对象的引用。请看下面的例子。
Expand Down