Map lưu key-value với key là bất kỳ type nào, iterable, có size. WeakMap chỉ nhận objects làm key, không iterable, không có size.
Key trong WeakMap là weak reference: nếu object bị garbage collect, entry tự động bị xóa. WeakMap dùng để associate data với object mà không ngăn GC.
Map stores key-value pairs where keys can be any type, is iterable, and has a size. WeakMap only accepts objects as keys, is not iterable, and has no size property.
Keys in WeakMap are weak references: if the object is garbage collected, the entry is automatically removed. WeakMap is used to associate data with an object without preventing garbage collection.