Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/typescript/8.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在Typescript中通过考虑对象的属性而不是对象的索引来编辑特定对象_Typescript - Fatal编程技术网

如何在Typescript中通过考虑对象的属性而不是对象的索引来编辑特定对象

如何在Typescript中通过考虑对象的属性而不是对象的索引来编辑特定对象,typescript,Typescript,我想通过考虑id而不是考虑数组的索引来编辑对象数组中的特定对象。数组如下所示 data_list = [ { { id: "001" name: "george", age : 20, address: "new york" }, { id: "002" name: "mavan",

我想通过考虑
id
而不是考虑数组的
索引来编辑对象数组中的特定对象。数组如下所示

data_list = [
    {
        {
            id: "001"
            name: "george",
            age : 20,
            address: "new york"
        },
        {
            id: "002"
            name: "mavan",
            age : 23,
            address: "new york"
        },
        {
            id: "003"
            name: "chris",
            age : 25,
            address: "melborn"
        },
        {
            id: "004"
            name: "jerry",
            age : 26,
            address: "dubai"
        }
    }
]
我想通过考虑
id
来编辑follow对象,正如我在上面所说的

{
    id: "003"
    name: "chris",
    age : 25,
    address: "melborn"
},
此对象应更改为此

{
    id: "003"
    name: "brown",
    age : 29,
    address: "Dilhi"
},
最后,数组应该如下所示

data_list = [
        {
            {
                id: "001"
                name: "george",
                age : 20,
                address: "new york"
            },
            {
                id: "002"
                name: "mavan",
                age : 23,
                address: "new york"
            },
            {
                id: "003"
                name: "brown",
                age : 29,
                address: "Dilhi"
            },
            {
                id: "004"
                name: "jerry",
                age : 26,
                address: "dubai"
            }
        }
    ]

那么我该怎么办呢

你确定第2行和接近尾端的花括号吗?对我来说似乎不是有效的ts。你确定第2行和接近结尾的那个花括号吗?对我来说这看起来不像是有效的ts。