Skip to content

Commit 3b0e603

Browse files
es10
1 parent e04c2da commit 3b0e603

File tree

6 files changed

+75
-11
lines changed

6 files changed

+75
-11
lines changed

01-JS语言基础/数据格式处理/01-正则表达式.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
reg.compile(reg);
4848

4949
// 【 3 字符串方法 】
50-
// match() 根据正则表达式去查找字符串符合规则的内容,返回数组,没有匹配项返回null
50+
// match() / matchAll() 根据正则表达式去查找字符串符合规则的内容,返回数组,没有匹配项返回null
5151
console.log(str.match(reg));// ["sun", "jian", "feng"]
5252
// replace()
5353
console.log("sunjianfeng".replace(/jianfeng/,"shine"));//sunshine

01-JS语言基础/数据类型与转换/String.html

+19-6
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,10 @@
4848
【 String.raw() 】转义字符串
4949
5050
【 es6 tag 函数 & template literals 】
51-
52-
【 es8 】
51+
【 es8 】
5352
* 【 padStart(), padEnd() 】字符串补全,比如统一数据前置0
53+
【 es10 】
54+
【 trimLeft() / trimRight() / trimStart() / trimEnd() 】
5455
5556
4.【简单综合应用1】字符串占位
5657
@@ -291,27 +292,39 @@
291292
/**
292293
* 【 模板字符串 】
293294
*/
295+
/*
296+
const basket = {
297+
count: 0,
298+
onSale: ['good1', 'good2']
299+
}
294300
`There are <b>${basket.count + 1}</b> items
295301
in your basket, <em>${basket.onSale}</em>${f()}
296302
are on sale!`
297303
// 标签模板
298304
alert`Hello world!`; // 等价于 alert('Hello world!')
299305
f`My Name is ${name},I am ${age+1} years old next year.`; // 等价于 f(['My Name is',',I am ',' years old next year.'],'Mike',28)
306+
*/
307+
300308
/**
301309
* 【 String.raw() 】
302310
* 转义字符串
303311
*/
304312

305313
/**
306-
* 【 padStart(), padEnd() 】
307-
* 字符串不够指定长度,在头部或尾部补全
308-
*/
314+
* 【 padStart(), padEnd() 】
315+
* 字符串不够指定长度,在头部或尾部补全
316+
*/
309317
'x'.padStart(4, 'ab') // 'abax'
310318
'x'.padEnd(5, 'ab') // 'xabab'
311319
'abc'.padStart(10, '0123456789') // '0123456abc'
312320
'x'.padEnd(4) // 'x '
313321
'7'.padStart(3, '0') // '007'
314-
322+
323+
/**
324+
* 【 trimLeft() / trimRight() / trimStart() / trimEnd() 】
325+
*/
326+
let strTrim = ' foo ' // strTrim.replace(/^\s+|\s+$/g, '')
327+
console.log(strTrim.trimStart()) // 'foo '
315328

316329
//【简单综合应用1】字符串占位
317330
var str = "CS逍遥剑仙 www.csxiaoyao.com";

02-ES新特性/09-ES6数组.html renamed to 02-ES新特性/09-Array数组.html

+6-4
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
// keys() 遍历键名
2323
// values() 遍历键值
2424
// includes() 数组是否包含指定值(es7)
25-
// flat() 嵌套数组转一维数组
25+
// flat() 嵌套数组转一维数组 (es10)
2626
// flatMap() 遍历元素再对数组执行 flat() 方法
2727
// ... 复制 / 合并数组
2828
// 数组缓冲区 ArrayBuffer / DataView
@@ -146,7 +146,7 @@
146146
console.log([...[,'a'].values()]); // [undefined, "a"] 数组含空位
147147

148148
/**
149-
* es6 数组包含
149+
* es7 数组包含
150150
*/
151151
// 【 includes() 】 数组是否包含指定值
152152
// 注意:与 Set 和 Map 的 has 方法区分:Set 的 has 方法用于查找值;Map 的 has 方法用于查找键名。
@@ -157,18 +157,20 @@
157157
[1, NaN, 3].includes(NaN); // true
158158

159159
/**
160-
* es6 嵌套数组转一维数组
160+
* es10 嵌套数组转一维数组
161161
*/
162162
// 【 flat() 】 嵌套数组转一维数组
163163
console.log([1 ,[2, 3]].flat()); // [1, 2, 3]
164164
console.log([1, [2, , 3]].flat()); // [1, 2, 3] 自动跳过空位
165165
// 指定转换的嵌套层数
166166
console.log([1, [2, [3, [4, 5]]]].flat(2)); // [1, 2, 3, [4, 5]]
167167
console.log([1, [2, [3, [4, 5]]]].flat(Infinity)); // [1, 2, 3, 4, 5]
168-
// 【 flatMap() 】 先对数组中每个元素进行处理,再对数组执行 flat() 方法
168+
// 【 flatMap() 】 flat + map 先对数组中每个元素进行处理,再对数组执行 flat() 方法
169169
// 参数1:遍历函数,该遍历函数可接受3个参数:当前元素、当前元素索引、原数组
170170
// 参数2:指定遍历函数中 this 的指向
171171
console.log([1, 2, 3].flatMap(n => [n * 2])); // [2, 4, 6]
172+
// 相当于
173+
console.log([1, 2, 3].map(n => [n * 2]).flat()); // [[2], [4], [6]] => [2, 4, 6]
172174

173175
/**
174176
* 扩展运算符

02-ES新特性/18-ES10-JSON.html

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<!--
2+
* @Author: victorsun
3+
* @Date: 2020-03-15 19:31:39
4+
* @LastEditors: victorsun - csxiaoyao
5+
* @LastEditTime: 2020-03-15 19:34:01
6+
* @Description: [email protected]
7+
-->
8+
<!DOCTYPE html>
9+
<html lang="en">
10+
<head>
11+
<meta charset="UTF-8">
12+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
13+
<title>es</title>
14+
</head>
15+
<body>
16+
<script>
17+
/**
18+
* ES10
19+
*/
20+
// 1. JSON bug 修复
21+
console.log(JSON.stringify('\u{D800}')) // 不报错了
22+
</script>
23+
</body>
24+
</html>

02-ES新特性/19-ES10-BigInt.html

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<!--
2+
* @Author: victorsun
3+
* @Date: 2020-03-15 19:31:39
4+
* @LastEditors: victorsun - csxiaoyao
5+
* @LastEditTime: 2020-03-15 20:44:11
6+
* @Description: [email protected]
7+
-->
8+
<!DOCTYPE html>
9+
<html lang="en">
10+
<head>
11+
<meta charset="UTF-8">
12+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
13+
<title>es</title>
14+
</head>
15+
<body>
16+
<script>
17+
/**
18+
* ES10
19+
*/
20+
const a = 11n
21+
typeof a // bigint
22+
typeof 11 // number
23+
</script>
24+
</body>
25+
</html>

0 commit comments

Comments
 (0)