通过 id 删除数组对象

remove array object by id

我正在尝试通过 ID 删除离子存储中的数组对象。但它没有按预期工作..我该怎么办。这是我的代码

page.ts

 removeItem(id){
    this.storage.get('storedAdd').then((val) => {
      console.log(Object.keys(val))
      Object.keys(val).splice(id, 1)
      console.log(val)
     for(let element of Object.keys(val)){
        console.log(val[element])
        val[element].id.toString().splice(id,1)
         this.storage.set('storeAdd', val)
          console.log(val)
     }
}

我使用 splice 但出现此错误

ERROR Error: Uncaught (in promise): TypeError: val[element].id.toString(...).splice is not a function
TypeError: val[element].id.toString(...).splice is not a function

Edit

我认为你不能在那里使用 toString,因为 splice() 方法通过删除或替换现有元素来更改数组的内容 and/or 在适当的位置添加新元素。 删除键的示例是 0:我使用了 delete

let myObject = {
  0: {
        "id" : 1,
        "text": "text1"
    },
 1: {
        "id" : 2,
        "text": "text2"
    }
};

delete myObject[0];
console.log(myObject);