How to create a dictionary in JavaScript?

To create a dictionary in JavaScript, create a new object like so: new Object().

Here's how you can create a dictionary, then add some values to it, then retrieve those values:

const dictionary = new Object();

dictionary['key1'] = 1;
dictionary['key2'] = 'Hello World!';

const valueUnderKey1 = dictionary['key1'];
const valueUnderKey2 = dictionary['key2'];

console.log(valueUnderKey1); // 1
console.log(valueUnderKey2); // Hello World!