I have an array typed like this :
array: {
[type: string]: string;
}
and i want to get all values from it without any keys.
I tried to get it in several ways but nothing..
Here is an example of code :
const array: {
[field: string]: string
} = {};
array['someProperty1'] = 'value1'
array['somePropert2'] = 'value2'
Here if i console log array
i get
{
array: {
someProperty1: 'value1',
someProperty2: 'value2'
}
}
And i just want to get an array with ['value1', 'value2']
您所说的“数组”在技术上不是数组,而是字典,但是您可以使用Object.values
轻松获取值:
const realArray = Object.values(array);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.