To add a hash table in JavaScript, we create an object literal.
For instance, we write
const myHash = {};
myHash["one"] = [1, 10, 5];
myHash["two"] = [2];
myHash["three"] = [3, 30, 300];
to define the myHash
object.
And then add keys and set them to values.
'one'
, 'two'
and 'three'
are the keys and the arrays are their values.