//1.数组中的实例方法
//实例方法调用必须通过实例对象(必须创建一个实例对象)
//reverse()翻转数组
//2.实例方法具体演示
//语法:数组实例对象.rever
//作用:将数组中的值进行翻转
//返回值:返回一个翻转后的一个值
// 代码演示:
// let ary = ['a', 'b', 'c', 'd'];
// // [d c b a]
// let newary = ary.reverse();
// console.log(newary);
//语法:数组实例的对象.concat();
//作用:合并数组
//代码演示:
// let ary1 = ['a', 'b', 'c'];
// let ary2 = [1, 2, 3];
// let ary3 = ary1.concat(ary2);
// console.log(ary3);
//语法:数组实例对象.join()
//作用:在数组中加入一个特殊的符号,得到一个新的字符串
//返回值:返回值就是一个字符串
//代码演示:
let ary = ['a', 'b', 'c'];
let str = ary.join('|');
console.log(str);
// typeof 验证他是什么类型
//indexOf()检索数组中的值 + lastIndexOf()检索数组中的值
//语法:数组实例对象.indexOf()
//作用:查找数组中是否包含某个值
//返回值:返回结果是一个数字,如果是-1代表没有该值,如果返回结果不是-1,代表有该值,返回结果是当前值对应的索引值
//特点:从数组中从前向后查找,如果找到直接返回对应的索引值
//区别:indexOf在数组中从前向后找 ,lastIndexOf从后往前找
// let ary = ['a', 'b', 'c'];
// let index = ary.indexOf('b')
// console.log(index);
//从后往前找
// let ary = ['a', 'b', 'c'];
// let index = ary.lastIndexOf('b')
// console.log(index);
//2.splice()
//语法:数组实例对象.splice(index,length)
//作用:删除数组中的值
//参数介绍:indexm,代表从哪删除, iength代表删除那个数
//3.
//-foEach
//-filter
//-map
//相同点
//1.参数都一样
//2.都可以实现遍历数组
//区别
//1.返回值不一样
//a)-foEach 不提供返回值
//b)-filter 返回的是一个数组,将遍历数组后,满足结果以数组方式返回
//c)-map返回的也是一个数组,数组中的个数跟原数组中是一样,将处理后的结果直接返回(数组中个数不会少)
//应用场景推荐:
//forEach,一般就是用来遍历数组的(与for循环一样)
// filter.一般用来筛选遍历的
//map,一般用来进行修改遍历的(映射)
//代码演示
let ary = ['a', 'b', 'c'];
//参数item表示数组中的值
//参数index表示数组中的索引
//参数中item和index可以不用设置,推荐设置item
// ary.forEach(function (item, index) {
// console.log(item);
// // console.log(index);
// })
// ary.filter(function(item,index){
// console.log(item);
// })
ary.map(function (item, index) {
console.log(item);
})