Skip to content

Commit 178e977

Browse files
update
1 parent 8410ff5 commit 178e977

File tree

2 files changed

+22
-3
lines changed

2 files changed

+22
-3
lines changed

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

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,9 +80,8 @@
8080
// g 全局模式(global)(全文查找出现的所有pattern)
8181
// i 不区分大小写(ease-insensitive)(忽略大小写)
8282
// m 执行多行匹配
83-
// y (es6) 相当于 ^$,保证每次匹配是连续的
8483
// u (es6) Unicode模式,正确处理大于\uFFFF的Unicode字符(四个字节的 UTF-16 编码)
85-
var s = '𠮷';
84+
var s = '𠮷'; // \uD842\uDFB7
8685
/^.$/.test(s); // false
8786
/^.$/u.test(s); // true 对于码点大于0xFFFF的 Unicode 字符,点字符不能识别,必须加上u修饰符
8887
/\u{61}/.test('a'); // false 误认为是量词,61个u
@@ -94,7 +93,7 @@
9493
/𠮷{2}/u.test('𠮷𠮷'); // true
9594
/^\S$/.test('𠮷'); // false \S是预定义模式,匹配所有非空白字符。只有加了u修饰符,它才能正确匹配码点大于0xFFFF的 Unicode 字符
9695
/^\S$/u.test('𠮷'); // true
97-
// y (es6) 粘连修饰符
96+
// y (es6) 粘连修饰符,相当于 ^$,保证每次匹配是连续的
9897
// s (es2018) 使.可以匹配任意单个字符(含行终止符)
9998
/foo.bar/s.test('foo\nbar') // true
10099

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

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@
4848
★【 matchAll() 】返回一个正则表达式在当前字符串的所有匹配
4949
【 String.raw() 】转义字符串
5050
51+
【 es6 tag 函数 & template literals 】
52+
5153
4.【简单综合应用1】字符串占位
5254
5355
5.【简单综合应用2】统计字符串中出现次数最多的字符和次数
@@ -361,6 +363,24 @@
361363
}
362364
}
363365

366+
/**
367+
* es6 tag 函数 & template literals
368+
*/
369+
function Price (strings, type) {
370+
let s1 = strings[0] // 您此次的
371+
const retailPrice = 20
372+
const wholeSalePrice = 16
373+
let showTxt
374+
if (type === 'retail') {
375+
showTxt = '购买单价是:' + retailPrice
376+
} else {
377+
showTxt = '购买的批发价是:' + wholeSalePrice
378+
}
379+
return `${s1}${showTxt}`
380+
}
381+
let showTxt = Price`您此次的${'retail'}`
382+
console.log(showTxt) // 您此次的购买单价是:20
383+
364384
</script>
365385
</body>
366386
</html>

0 commit comments

Comments
 (0)