April 2018
Beginner to intermediate
426 pages
10h 19m
English
Next, we have the set method, as declared in the following code:
set(key, value) { if (key != null && value != null) { const tableKey = this.toStrFn(key); // {1} this.table[tableKey] = new ValuePair(key, value); // {2} return true; } return false;}
This method receives a key and a value parameter. If the key and value are not undefined or null, then we get the string that represents the key ({1}) and we create a new value pair and assign it to the key string (tableKey) property in the table object ({2}). If the key and value are valid, we also return true, indicating the dictionary was able to store the key and value, otherwise, we return false.
This method can be used to ...