ITPub博客

首页 > > > JS 数组去重

JS 数组去重

作者:doudourabbit 时间:2019-09-11 15:09:23 0 删除 编辑


题目:移除数组 arr 中的所有值与 item 相等的元素,并将结果返回 。

要求:1:直接在给定的 arr 数组上进行操作。

   2:数组顺序不可打乱。

如:function removeWithoutCopy(arr,item)

  {

    /*

      your code

    */

    return arr;

  }

  console.log(removeWithoutCopy([3,1,4,2],2));//输出[3,1,4]

  来试试吧!

来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/4809/viewspace-3139680/ ,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论

注册时间:2019-04-25

  • 博文量
    193
  • 访问量
    1436