TGViewer
JavaScript JavaScript @javascript · 31.1K subscribers
Post #3412 2.3K
CHALLENGE

class Config {
constructor(options = {}) {
this.retries = options.retries ?? 3;
this.timeout = options.timeout ?? 1000;
}
}
const cfg1 = new Config({ retries: 0, timeout: null });
const cfg2 = new Config({ retries: undefined, timeout: false });
cfg1.retries ??= 99;
cfg2.timeout ??= 99;
console.log(cfg1.retries, cfg1.timeout, cfg2.retries, cfg2.timeout);
  • ❤ 3
  • 🔥 1
More from @javascript
  1. Sep 20, 2026Post #3507
  2. Sep 20, 2026CHALLENGE 'use strict'; function getValue() { return this.value; } const obj = { value: 42…
  3. Sep 19, 2026Post #3505
  4. Sep 19, 2026CHALLENGE const a = 5 & 3; const b = 5 | 2; const c = ~5; const d = 1 << 31; const e = -1…
  5. Sep 18, 2026Post #3503
  6. Sep 18, 2026CHALLENGE let i = 0; const key = () => `k${i++}`; const obj = { [key()]: i, [key()]: i, [k…
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 →