weakMap의 clear 메소드는 WeakMap 객체에서 모든 키/값 쌍을 제거합니다.
이 메서드는 사양에서 제거되었으며 Clear 메서드에 대한 지원이 추가된 WeakMap 개체를 래핑하여 다시 추가할 수 있습니다.
예시
class ClearableWeakMap {
constructor(init) {
this._wm = new WeakMap(init)
}
clear() {
this._wm = new WeakMap()
}
delete(k) {
return this._wm.delete(k)
}
get(k) {
return this._wm.get(k)
}
has(k) {
return this._wm.has(k)
}
set(k, v) {
this._wm.set(k, v)
return this
}
}