Is it good to use an object literal as a hash table? use the property name as the key to return the specific display value.
For instance:
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 template that handles the hash map better in JavaScript?
source
share