TGViewer
JavaScript test JavaScript test @js_test · 9.74K subscribers
Post #6413 412
❗️Что будет на выходе:

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 & Max
More from @js_test
  1. Sep 27, 2026❗️Что будет на выходе: function processConfig(config) { const cache = config.cache ?? true…
  2. Sep 27, 2026Хочешь заговорить на английском, но не с кем практиковаться? Появилась ИИ-девушка, с котор…
  3. Sep 27, 2026❗️Что будет на выходе? const user = { profile: { name: 'Alice', settings: { notifications:…
  4. Sep 26, 2026❓Что будет на выходе? function recursivePascalTriangle(n, row = [1], triangle = []) { tria…
  5. Sep 26, 2026❗️Что будет на выходе: const regex = /a/g; const str = 'banana'; console.log(str.match(reg…
  6. Sep 26, 2026❗️Что будет на выходе: class MyClass { constructor() { this.a = 100; } } MyClass.prototype…
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 →