es6中对数组的常用操作方法(二)

补充上节数组未用到的数组方法

//定义的普通数组arr以及对象数组
      arr: [1, 2, 3, 4, 5],
      arrObject: [
        { name: 'n1', title: 't1' },
        { name: 'n2', title: 't2' },
        { name: 'n3', title: 't3' }
      ]  
 //1.三个...
      // const arrNew = [...this.arr, ...this.arrObject];
      // console.log('arrNew', arrNew);
      //2.indexOf
      // const index = this.arr.indexOf(2);
      // console.log('内容为2的数组的值:', this.arr[index]);
posted on 2024-07-26 18:12  技术高超  阅读(7)  评论(0编辑  收藏  举报