Array.prototype.indexof(value):得到值在数组中的第一个下标

Array.prototype.lastIndexof(value):得到值在数组中的最后一个下标

Array.prototype.foreach(function(item,index){}):遍历数组

Array.prototype.map(function(item,index){}):遍历数组返回一个加工之后的数组,返回加工之后的值

Array.prototype.filter(function(item,index){}):遍历过滤一个新的数组,返回条件为true的值

例子:

        var arr = [5,4,8,6,9,4,5,8,2,6,4,1,0];
        console.log(arr.indexOf(5));
        console.log(arr.lastIndexOf(5));
        arr.forEach(function(item,index){
            console.log('下标:'+index+','+'值:'+item);
        });
        console.log(arr.map(function(item,index){//返回一个将原数组中的值加10后的新数组
            return item+10;
        }));
        console.log(arr.filter(function(item,index){//返回原数组中大于5的数为一个新的数组
            return item>5;
        }));

最新文章

  1. Android Intent
  2. 在Ubuntu14.04下安装运行Unity-tweak-tool报错scheme missing的解决办法
  3. HDU 3231 Box Relations
  4. MySQL 5.7 基于复制线程SQL_Thread加快恢复的尝试
  5. display inline or block
  6. Django2.X报错-------ModuleNotFoundError: No module named 'django.core.urlresolvers'
  7. iReport 5.6.0 启动闪退的问题 解决方案
  8. redis底层设计(一)——内部数据结构
  9. Nginx 添加 PHP 支持
  10. 004 Java的一次面试题,学长列举
  11. html页面出现&#65279,影响布局
  12. c#中富文本编辑器Simditor带图片上传的全部过程(项目不是mvc架构)
  13. input框触发回车事件
  14. Mongodb 基础 查询表达式
  15. 牛客国庆集训派对Day3 B Tree
  16. C:基础知识
  17. spring boot 下载
  18. linux c 编程相关资料
  19. Ng第十七课:大规模机器学习(Large Scale Machine Learning)
  20. springmvc+mybatis 根据数据的id删除数据

热门文章

  1. D. Mahmoud and Ehab and another array construction task 因子分界模板+贪心+数学
  2. xv6 trapframe定义的位置
  3. 深入delphi编程理解之接口(一)接口与类的异同及接口的声明和实现
  4. 1.3 使用jmeter进行http接口测试
  5. XSS常见攻击与防御
  6. java获取配置文件中变量值
  7. 任意模数 n 次剩余
  8. 改变input[type=range]的样式 动态滑动
  9. linux的mysql主从
  10. 存储引擎,MySQL中的数据类型及约束