How can str in obj be read as a variable?

 const str=item.tag1.substring(2,10).split(",").join("");
                        const obj={str:{
                            "Value":item.value,
                            "vr":item.vr
                            }
                        }
How can the str in

obj be read as a variable?

Dec.28,2021

doesn't quite understand your description. If you want to use the variable str as the attribute name of obj , you can write

like this.
const str = item.tag1.substring(2, 10).split(',').join('');
const obj = {
  [str]: {
    'Value': item.value,
    'vr': item.vr,
  },
};

problem description is unclear
Please specify the expected result

Menu