var arr = [1,2,3,4,5];
//遍历数组的主要的方法为:for()、forEach()、map()、for..in()、for...of()。
//for
// for (let i = 0, len= arr.length;i<len;i++){
// console.log(arr[i])
// }
// for(let i =0;i<arr.length;i++){
// console.log(arr[i])
// }
// forEach
// var obj = {a:1}
// arr.forEach(function(currentValue,index,array){
// console.log('当前值',currentValue)
// console.log("当前值索引",index)
// console.log("当前处理数组",array)
// console.log('当前this指向',this)
// },obj)
// map
// var obj ={a:1}
// var newArr=arr.map(function(currentValue,index,array){
// console.log("当前值",currentValue);
// console.log("当前值索引",index);
// console.log("当前处理数组",array);
// console.log("当前this指向",this);
// return currentValue + 10
// },obj)
// console.log(newArr)
// for in 方法遍历数组效率非常低
// for(let item in arr){
// console.log(arr[item])
// }
//for..in是为遍历对象属性而构建的
// var obj={a:1,b:2}
// for(let item in obj){
// console.log(obj[item])
// }
// for of
// for(let value of arr){
// console.log(value)
// }
//Array.prototype 还提供了对于数组的判断与过滤操作,every()、some()、find()、findIndex()、filter()。
// arr.every(callback(element[,index[,array])[,thisAry])
//every()方法测试一个数组内的所有是否都通过某个指定函数的测试。它返回一个布尔值
// console.log(arr.every((currentValue)=>{
// return currentValue > 1
// }))
// console.log(arr.every((currentValue)=>{
// return currentValue > 0
// }))
// arr.some(callback(element[,index[,array])[,thisAry])
//some()方法测试数组中是不是至少1个元素过了被提供的函数测试。它返回的是一个Boolean类型的值
// console.log(arr.some((currentValue)=>{
// return currentValue > 1
// }))
// console.log(arr.some((currentValue)=>{
// return currentValue > 6
// }))
//arr.find(callback(element[,index[,array])[,thisAry])
//find()方法返回数组中满足提供的测试函数的第一个元素的值。否则返回undefined
// console.log(arr.find((currentValue)=>{
// return currentValue > 2
// }))
// console.log(arr.find((currentValue)=>{
// return currentValue > 6
// }))
// arr.findIndex(callback(element[,index[,array])[,thisAry])
//findIndex()方法返回数组中满足提供的测试函数的第一个元素的索引,否则返回-1
// console.log(arr.findIndex((currentValue)=>{
// return currentValue > 2
// }))
// console.log(arr.findIndex((currentValue)=>{
// return currentValue > 6
// }))
//arr.filter(callback(element[,index[,array])[,thisAry])
//filter()方法创建一个新数组,其包含通过所提供函数实现的测试的所有元素
// console.log(arr.filter((currentValue)=>{
// return currentValue > 2
// }))
console