I have this array ["one","two","three"] would like to convert it into this {one:true, two:true, three:true}. Basically what am doing is converting the array items to keys of an object and make them boolean. I have tried using spread operator {... arr} which results to {0:'one',1:'two',2:'three'}, Any Ideas?
You could map objects and assign them to a single object.
var array = ["one", "two", "three"],
object = Object.assign(...array.map(k => ({ [k]: true })));
console.log(object);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With