update: 模板字符串
This commit is contained in:
@@ -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()
|
||||
|
||||
**语法**:
|
||||
|
||||
Reference in New Issue
Block a user