如何通过打字稿中的对象数组删除特定对象

时间:2019-04-20 14:19:59

标签: typescript

我想从对象数组中删除特定对象。数组如下

    data_list = [
        {
            {
                name: "george",
                age : 20,
                address: "new york"
            },
            {
                name: "mavan",
                age : 23,
                address: "new york"
            },
            {
                name: "chris",
                age : 25,
                address: "melborn"
            },
            {
                name: "jerry",
                age : 26,
                address: "dubai"
            }
        }
    ]

我想通过考虑name属性来删除关注对象。即chirs

{
    name: "chris",
    age : 25,
    address: "melborn"
},

我应该怎么做

1 个答案:

答案 0 :(得分:1)

data_list = data_list.filter(obj => obj.name !== 'chris')