interface Map<K, V> {
//清空
clear(): void;
//删除:通过key来删除value
delete(key: K): boolean;
//遍历
forEach(callbackfn: (value: V, key: K, map: Map<K, V>) => void, thisArg?: any): void;
//通过key获得value
get(key: K): V | undefined;
//判断是否存在对应的key值
has(key: K): boolean;
set(key: K, value: V): this;
//获取map长度
readonly size: number;
}
//遍历Map
for(const [key,value] of map){ console.log(key,value); }

Logo

权威|前沿|技术|干货|国内首个API全生命周期开发者社区

更多推荐