You should just use Array.prototype.map() to create a new, mutated array rather than worrying about creating temporary arrays, mutating them and then assigning them.
const BbDescriptionDictionary = ['AAA' , 'BBB', 'CCC',]
// Map runs the function on each array item and returns a new array
// with mutated the return value of that function
// Note: ({ ... }) is a shorthand way of returning a value
// (object in this case) without a function body {}
this.boardBasisOptions = this.boardBasisOptions.map((key, index) => ({
// Shorthand way of assigning a variable to an object using the var
// name as the key
key,
value: BbDescriptionDictionary[index]
})
Its is considered bad practice to override properties like this, so I would return the original boardBasisOptions to a a new property and use that later on:
const BbDescriptionDictionary = ['AAA' , 'BBB', 'CCC',]
this.boardBasisOptionsWithDescriptions = this.boardBasisOptions.map((key, index) => ({
key,
value: BbDescriptionDictionary[index]
})
Hope that helps 👍
boardBasisOptions?BbDescriptionDictionary[value]will translate toBbDescriptionDictionary['AAA'], while it should beBbDescriptionDictionary[0].