So I have an array of objects [{}, {}, {}]
and simple array [true, false, true]
Is there any way to make first array [{value: true}, {value: false}, {value: true}]?
I mapped over the object array
const a = [{a: 1}, {a: 2}, {a: 3}] const b = [true, false, true] const c = a.map((item) => {...item, value: })
I don't understand how to assign the value from the second array.
Assuming your array of objects is called objects and your simple array is called array, then you can execute:
objects.forEach((o, i) => o['value'] = array[i])
You can map each element of the array to the object:
console.log([true, false, true].map(el => ({ value: el })));
or if you want to overwrite the elements in the first array
const arr = [{}, {}, {}];
const arr2 = [true, false, true];
arr.forEach((el, idx) => el.value = arr2[idx]);
console.log(arr);
An alternative way of accomplishing this is by using the unshift() method which will add the new elements to the beggining of the array.
var arr1 = [true, false, true], arr2 = [{}, {}, {}];
for(el of arr1){ arr2.unshift({'value': el}) }
console.log(arr2);
If you want to loose the last three empty objects in the array, slice them like so: arr2.slice(0,3)