I tried this but it only set the value to obj1
let obj1, obj2, obj3, obj4, ..., objn = {} // only obj1 is set, the rest is undefined.
I looked at this post: assign multiple variables to the same value in Javascript and they suggested this:
let obj1 = obj2 = obj3 = obj4 = ... = objn = {}
But the above says that any change in obj1
will affect obj2
, obj3
, ...
Is is possible to initialize all obj
as {}
at once without a for loop ?