【发布时间】:2020-02-27 06:43:40
【问题描述】:
下面有一个示例代码
let arr = [
{ name:"string 1", value:"value1", other: "other1" },
{ name:"string 2", value:"value2", other: "other2" }
];
let obj = arr.find((o, i) => {
arr[i] = { name: 'new name', value: 'new value', other: 'that' };
return true; // stop searching
});
console.log(arr);
我想用名称“新名称”和值“新值”替换所有数组值,现在它只更改第一个数组索引值。
【问题讨论】:
标签: javascript typescript