Is it good practice to use a object literal as a hash table? i.e use a property name as the key to get a particular mapped value back.
For example:
var colorArray = [
{ code: "#4286f4", name: "Blue" },
{ code: "#fc4d02", name: "Red" }
]
var hashTable = {}
colorArray.forEach(color => {
hashTable[color.code] = color.name
})
Is this an acceptable use for object literals, or is there a pattern out there that will better handle a hash map in JavaScript?