TGViewer
JavaScript test JavaScript test @js_test · 9.7K subscribers
Post #5281 705
❗️Что будет на выходе:
const memoryLeak = () => {
const cache = new Map();
const weakCache = new WeakMap();

const objKey = { id: 123 };
const data = { name: 'User data', value: 42 };

cache.set(objKey, data);
weakCache.set(objKey, data);

// Simulate removing reference to key
const result = { map: cache.has(objKey), weakMap: weakCache.has(objKey) };
// objKey = null; // This would be an error, as const can't be reassigned

return result;
};

console.log(memoryLeak());


Ответ: { map: true, weakMap: true }

JavaScript test | #JavaScript
More from @js_test
  1. Oct 10, 2026❗️Что будет на выходе: async function fetchData() { return 'Data loaded'; } async function…
  2. Oct 10, 2026Муха освоила нейросети и умеет трейдить, играть в гта, делать ставки, а ты пользуешься тол…
  3. Oct 10, 2026❗️Что будет на выходе: function highlight(strings, ...values) { return strings.reduce((res…
  4. Oct 10, 2026❓Что будет на выходе? const a = '10'; const b = 20; const c = '30.5'; const result = Numbe…
  5. Oct 9, 2026❗️Что будет на выходе: function* gen() { yield 1; yield 2; yield 3; } async function async…
  6. Oct 9, 2026❗️Что будет на выходе: const person = { name: 'Alice', greet() { return `Hello, I'm ${this…
Threads Profile ViewerView any public Threads profile without an account.Open ThreadLook →Writing with AI? Make it sound human.Metric37 rewrites AI drafts so they read naturally. Free AI detector, 1,500 words free.Try Metric37 →