const map = new WeakMap();
let obj1 = { name: 'user1' };
let obj2 = { name: 'user2' };
map.set(obj1, 'data for user1');
map.set(obj2, 'data for user2');
console.log(map.has(obj1));
obj1 = null;
// After garbage collection runs
console.log(map.has(obj1));
console.log(map.get(obj2));
Ответ:
Please open Telegram to view this post
VIEW IN TELEGRAM
console.log(1);
setTimeout(() => console.log(2), 0);
Promise.resolve()
.then(() => {
console.log(3);
return Promise.resolve(4);
})
.then(console.log);
console.log(5);
Ответ:
Please open Telegram to view this post
VIEW IN TELEGRAM