For example, consider the following TypeScript enum:
export enum UserType {
Guest = 1,
SNS = 2,
Account = 3,
Certified = 4,
}
Is there a way to dynamically create an array with specific values without hard-coding them?
const atrributeOptions = [
{
type: UserType.Guest,
isSelect: filterCondition.filter((item) => item.type === UserType.Guest)[0].isSelect,
onClick: this.onToggleFilterItem.bind(this, UserType.Guest),
},
{
type: UserType.Certified,
isSelect: filterCondition.filter((item) => item.type === UserType.Certified)[0].isSelect,
onClick: this.onToggleFilterItem.bind(this, UserType.Certified),
},
{
type: UserType.Account,
isSelect: filterCondition.filter((item) => item.type === UserType.Account)[0].isSelect,
onClick: this.onToggleFilterItem.bind(this, UserType.Account),
},
{
type: UserType.SNS,
isSelect: filterCondition.filter((item) => item.type === UserType.SNS)[0].isSelect,
onClick: this.onToggleFilterItem.bind(this, UserType.SNS),
},
];