concept
A dictionary is also a data structure that stores unique values , but it is stored in the form of key-value pairs .
Common operations of the dictionary: add, delete, modify, and check.
achieve
Available Map()
representation dictionaries in JavaScript :
const m = new Map();
// 增
m.set('a', 'aaa');
m.set('b', 'bbb');
m.set('c', 'ccc');
// Map(3) { 'a' => 'aaa', 'b' => 'bbb', 'c' => 'ccc' }
// 删
m.delete('b');
// Map(2) { 'a' => 'aaa', 'c' => 'ccc' }
m.clear();
// Map(0) {}
// 改
m.set('a', 'aaa');
m.set('b', 'bbb');
m.set('a', '11111');
// Map(2) { 'a' => '11111', 'b' => 'bbb' }
// 查
console.log(m.get('a'));
// 11111