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

const user = { name: 'Alice' };
const ratings = new WeakMap();

ratings.set(user, 5);
const result = [];

result.push(ratings.has(user));
result.push(ratings.get(user));

// Create a reference-free object
let tempUser = { name: 'Bob' };
ratings.set(tempUser, 10);
result.push(ratings.has(tempUser));

// Remove the reference
tempUser = null;

// Try to iterate through WeakMap
result.push(typeof ratings[Symbol.iterator]);

console.log(result);


Ответ: [true, 5, true, 'undefined']

JavaScript test | #JavaScript
More from @js_test
  1. Oct 14, 2026❗️Что будет на выходе: function processData({ a = 10, b = 20 } = { a: 30 }) { console.log(…
  2. Oct 14, 2026Как платить за границей и за зарубежные сервисы в 2026 году? Можно переплачивать посредник…
  3. Oct 14, 2026❗️Что будет на выходе: const person = { name: 'Alice', greet() { return `Hello, I'm ${this…
  4. Oct 14, 2026❗️Что будет на выходе: const regex = /a/g; const str = 'banana'; console.log(str.match(reg…
  5. Oct 13, 2026❓Что будет на выходе? const sym1 = Symbol('description'); const sym2 = Symbol('description…
  6. Oct 13, 2026❗️Что будет на выходе: function Animal(name) { this.name = name; } Animal.prototype.speak…
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 →