const fields = [\'email\', \'password\'];
const objFields = {};
fields.forEach(value => {
objFields[value] = \'\';
});
console.log(objFiel
In modern browsers, or by using polyfills, you can use Object.fromEntries() to create an object from an array, using the array's values as keys/properties, and fill the object's values with a default.
const fields = ['email', 'password'];
const result = Object.fromEntries(fields.map(value => [value, '']));
The result is {email: "", password: ""}
.