字典是什么 ?
字典也就是一种类似于数据的数据结构,他的出现就是为了,前端做输入框的时候限制用户输入的值,只不过字典这个数组中的元素是以 key:value的形式存在的;
// 字典class Dictionary {constructor(){this.store = [];}// 查找get(key){return this.store[key];}// 添加set(key,val){this.store[key] = val;}// 包含has(key){return this.store.includes(key);}// 删除delete(key){// 如果不包含返回falseif(!this.has(key)) return false;delete this.store[key];}show(){console.log(this.store);}}let a = new Dictionary();a.set('name','xtt');a.set('age','18');a.show();// 古有诸葛亮fuz
