fill all field of object in js 1

fill all field of object in js

let obj = new obj()

Object.keys(obj).forEach(field => obj[field] = 'value');
// fill all fields of obj with 'value'

Here is what the above code is Doing:
1. Create a new object
2. Get all the keys of the object
3. Iterate over the keys
4. Set the value of each key to ‘value’

Similar Posts