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

class Session {
#id;
constructor(id) {
this.#id = id;
}
getId() {
return this.#id;
}
}

const activeSessions = new WeakSet();

const s1 = new Session("alpha");
const s2 = new Session("beta");
let s3 = new Session("gamma");

activeSessions.add(s1);
activeSessions.add(s2);
activeSessions.add(s3);

console.log(activeSessions.has(s1));
console.log(activeSessions.has(s3));

activeSessions.delete(s2);
console.log(activeSessions.has(s2));

try {
activeSessions.add("invalid");
} catch (e) {
console.log(e instanceof TypeError);
}

console.log(activeSessions.has(s1));

Ответ: true true false true true

JavaScript test | #JavaScript & Max
More from @js_test
  1. Sep 28, 2026❗️Что будет на выходе? const arr = []; arr.length = 3; arr[10] = 7; arr.forEach((el, i) =>…
  2. Sep 28, 2026👩‍💻 Всем программистам посвящается! Вот 14 авторских обучающих IT каналов по самым востр…
  3. Sep 27, 2026❗️Что будет на выходе: function processConfig(config) { const cache = config.cache ?? true…
  4. Sep 27, 2026Хочешь заговорить на английском, но не с кем практиковаться? Появилась ИИ-девушка, с котор…
  5. Sep 27, 2026❗️Что будет на выходе? const user = { profile: { name: 'Alice', settings: { notifications:…
  6. Sep 26, 2026❓Что будет на выходе? function recursivePascalTriangle(n, row = [1], triangle = []) { tria…
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 →