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

const wm = new WeakMap();
let obj1 = { name: 'John' };
let obj2 = { name: 'Jane' };

wm.set(obj1, 'developer');
wm.set(obj2, 'designer');

console.log(wm.get(obj1));
console.log(wm.has(obj2));

obj1 = null;
console.log(wm.get(obj1));

const normalObj = {};
try {
wm.set('string', 'value');
} catch (e) {
console.log('error');

}

Ответ: developer true undefined error


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 →