P粉4125335252023-09-04 10:47:27
The simplest way to modify the original array
arrObj.forEach(item => item.status = arr.includes(item.name)) console.log(arrObj);
<script> let arrObj = [{ name: "Test1", status: false }, { name: "Test2", status: false }, { name: "Test3", status: false } ] let arr = ["Test1", "Test3"]; </script>
Typescript Version Types inferred by running the same script as the one I have posted