JavaScript/array/find

来自康健生活

引言

other

find 方法会更改引用

const source = [1,2,3];
const target = source.find(_ => _ === 1);
source[0] = 4;
console.log(source);
console.log(target);
[4, 2, 3]
1