update: 模板字符串

This commit is contained in:
qianguyihao
2020-08-25 20:47:55 +08:00
parent 516051b422
commit bae724f3bd
6 changed files with 204 additions and 240 deletions

View File

@@ -48,6 +48,7 @@
| :-------------------- | :----------------------------------------------------------------------------- | :------------------------------------------------------- |
| indexOf(value) | 从前往后索引检索一个数组中是否含有指定的元素 | |
| lastIndexOf(value) | 从后往前索引检索一个数组中是否含有指定的元素 | |
| includes(item) | 数组中是否包含指定的内容 | |
| find(function()) | 找出**第一个**满足指定条件返回 true的元素 | |
| findIndex(function()) | 找出**第一个**满足指定条件返回 true的元素的 index | |
| every() | 确保数组中的每个元素都满足指定条件返回 true则停止遍历此方法才返回 true | 全真才为真要求每一项都返回 true最终的结果才返回 true |
@@ -869,6 +870,26 @@ console.log(result); // 打印结果9
上方代码中`indexOf()`方法中携带了两个参数具体解释请看注释
## includes()
**语法**
```js
布尔值 = arr.includes(想要查找的元素, [position]);
```
**解释**判断一个数组中是否包含指定的元素如果是则会返回 true否则返回 false
参数中的 `position`如果不指定则默认为0如果指定则规定了检索的起始位置
```js
const arr = [11, 12, 13, 14, 15];
console.log(arr.includes(12)); // 打印结果true
console.log(name.includes(20)); // 打印结果false
console.log(name.includes(11, 1)); // 打印结果false
```
## find()
**语法**