I want to convert this:
let arr = ['a', 'b', 'c'];
To this:
let obj = { a: null, b: null, c: null };
Thank you :)
I want to convert this:
let arr = ['a', 'b', 'c'];
To this:
let obj = { a: null, b: null, c: null };
Thank you :)
console.log(
Object.fromEntries(['a', 'b', 'c'].map(x => ([x, null])))
);
You could use Array#map and object entries to get the desired results you are after.
Demo:
let arr = ['a', 'b', 'c'];
let conv = Object.fromEntries(arr.map(y => ([y, null])))
console.log(conv)