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

function processConfig(config) {
const defaultPort = 8080;
const defaultTimeout = 5000;

const port = config?.port ?? defaultPort;
const timeout = config?.timeout ?? defaultTimeout;
const debug = config?.debug ?? false;

return {
summary: `Port: ${port}, Timeout: ${timeout}, Debug: ${debug ? 'enabled' : 'disabled'}`,
isUsingDefaults: port === defaultPort && timeout === defaultTimeout
};
}

const result = processConfig({ port: 0, timeout: null });
console.log(result.summary);


Ответ: Port: 0, Timeout: 5000, Debug: disabled

JavaScript test | #JavaScript
More from @js_test
  1. Oct 16, 2026❗️Что будет на выходе: const memoryLeak = () => { const cache = new Map(); const weakCache…
  2. Oct 16, 2026❗️Что будет на выходе: const createMathOps = (base) => { return { add: (x) => base + x, mu…
  3. Oct 16, 2026❗️Что будет на выходе: const person = { name: 'Alice', greet() { return `Hello, I'm ${this…
  4. Oct 15, 2026❗️Что будет на выходе: try { try { // Creating a custom error type class CustomError exten…
  5. Oct 15, 2026❗️Что будет на выходе: const createMathOps = (base) => { return { add: (x) => base + x, mu…
  6. Oct 15, 2026❗️Что будет на выходе: const team = { name: 'Eagles', players: ['Smith', 'Johnson', 'Willi…
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 →