Is it feasible to achieve the following functionality without utilizing a map
, reduce
, or any other functions?
const arr1 = ['str', 'str2'];
let obj = {};
Object.assign(obj, [...arr1] : 'Value');
console.log(obj); // Anticipated result: { str1: 'Value', str2: 'Value' }
The objective is to transform each element of an array into an object key and assign it a fixed value. The syntax in question involves potential destructuring similar to the provided pseudo code. I am curious if this can be accomplished using a simple approach without additional functions. With no available information on this method, my curiosity led me to seek clarification on this matter.