I have array (API response):
let arr = [
{ '@type': 'Something', data: 1234 },
{ '@type': 'Something', data: 3214 },
]
Is it possible to destructure elements with those '@' prefixed fields?
for (const { data, ??? @type } of arr) {}
I have array (API response):
let arr = [
{ '@type': 'Something', data: 1234 },
{ '@type': 'Something', data: 3214 },
]
Is it possible to destructure elements with those '@' prefixed fields?
for (const { data, ??? @type } of arr) {}
You could take a computed property and a new variable name.
let arr = [{ '@type': 'Something', data: 1234 }, { '@type': 'Something', data: 3214 }];
for (const { data, ['@type']: renamed } of arr) {
console.log(renamed);
}