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

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. Oct 16, 2026❗️Что будет на выходе: const createMathOps = (base) => { return { add: (x) => base + x, mu…
  2. Oct 16, 2026❗️Что будет на выходе: const person = { name: 'Alice', greet() { return `Hello, I'm ${this…
  3. Oct 15, 2026❗️Что будет на выходе: try { try { // Creating a custom error type class CustomError exten…
  4. Oct 15, 2026❗️Что будет на выходе: const createMathOps = (base) => { return { add: (x) => base + x, mu…
  5. Oct 15, 2026❗️Что будет на выходе: const team = { name: 'Eagles', players: ['Smith', 'Johnson', 'Willi…
  6. Oct 14, 2026❗️Что будет на выходе: function processData({ a = 10, b = 20 } = { a: 30 }) { console.log(…
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 →