1// Dictionaries are placed in braces, and values are seperated with a comma
2let myDictionary = {
3 "value 1": "string",
4 "value 2": 2,
5 "value 3": ["array value 1", "array value 2"]
6};
7
8// Access the dictionary using its keys
9var value1 = myDictionary["value1"]; // Type: String
10var value2 = myDictionary["value2"]; // Type: Int
11var value3 = myDictionary["value3"]; // Type: Array
1// Javascript Dictionary
2Output : s_dict = { "var_name":1, "var_age": 50 }
3//create
4var s_dict = new Object();
5// or
6var s_dict = {};
7
8// Add to Dictionary ('dict')
9s_dict["var_name"] = 1;
10// or
11s_dict[2] = 50;
12// or
13s_dict.var_name = 1
14
15//Accessing Dictionary
16foo = s_dict["var_name"]
17// or
18foo = s_dict.var_name
19
20//Delete key from Dictionary
21delete s_dict['var_name']
1var test_dictionary = {
2 "This is a key" : "This is the value of this key",
3 "You can make many keys" : {
4 // You can even nest dictionaries in one another
5 "Integer" : 123,
6 "String" : "Hello, world!",
7 "Boolean" : true,
8 "Array" : [1,2,3,4,5]
9 }
10}