TGViewer
JavaScript test JavaScript test @js_test · 9.68K subscribers
Post #4890 765
❗️Что будет на выходе:
function processInput(userInput) {
const defaultValue = 'default';
const value1 = userInput?.value ?? defaultValue;
const value2 = userInput?.value || defaultValue;

const result = {
a: 0 ?? 'zero',
b: '' ?? 'empty',
c: null ?? 'null',
d: undefined ?? 'undefined',
comparison: value1 === value2
};

console.log(result);
}

processInput({ value: '' });


Ответ: { a: 0, b: '', c: 'null', d: 'undefined', comparsion: false}

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 →