从ID数组中删除用户ID

时间:2019-09-06 17:31:01

标签: javascript

我想从数组中删除用户ID(有两个)

const user = {
  "_id": "5d6caefdbb6f2921f45caf1d"
}

const allowners = [
  "5d6caefdbb6f2921f45caf1d",
  "5d6caee9bb6f2921f45caf1b",
  "5d6dfcd6e3b11807944348b8",
  "5d6caefdbb6f2921f45caf1d"
];

const vendors = []
allowners.forEach((allowner) => {
  if (allowner != user._id) {
    vendors.push(allowners)
  }
})
console.log(vendors, user._id)

0 个答案:

没有答案