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

function processConfig(config) {
const defaults = {
timeout: 1000,
retries: 3,
enabled: false,
count: 0
};

const settings = {
...defaults,
...config
};

const effectiveTimeout = settings.timeout ?? 500;
const effectiveRetries = settings.retries ?? 1;
const effectiveEnabled = settings.enabled ?? true;
const effectiveCount = settings.count ?? 5;

console.log([effectiveTimeout, effectiveRetries, effectiveEnabled, effectiveCount]);
}

processConfig({ timeout: null, retries: 0, enabled: undefined });

Ответ: [500, 0, true, 0]

JavaScript test | #JavaScript
More from @js_test
  1. Oct 15, 2026❗️Что будет на выходе: try { try { // Creating a custom error type class CustomError exten…
  2. Oct 15, 2026❗️Что будет на выходе: const createMathOps = (base) => { return { add: (x) => base + x, mu…
  3. Oct 15, 2026❗️Что будет на выходе: const team = { name: 'Eagles', players: ['Smith', 'Johnson', 'Willi…
  4. Oct 14, 2026❗️Что будет на выходе: function processData({ a = 10, b = 20 } = { a: 30 }) { console.log(…
  5. Oct 14, 2026Как платить за границей и за зарубежные сервисы в 2026 году? Можно переплачивать посредник…
  6. Oct 14, 2026❗️Что будет на выходе: const person = { name: 'Alice', greet() { return `Hello, I'm ${this…
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 →