JS Array集合的操作

类似于Java的Stream流的操作。

studentList为List对象

let a = studentList.map(x => x.name);//获取List对象的某一列的值
console.log(a.join(','));//打印出来,用逗号分隔

 删除list中的某个指定的元素:

  remove(e){
    this.fileList.splice(this.fileList.findIndex(item=>item===e), 1)
  }

 给数组的首位添加一个或多个元素:

let temp = arr.unshift(1)

 

posted @ 2022-02-17 17:20  盐排骨  阅读(177)  评论(0编辑  收藏  举报