B) Answer In JavaScript, when you write return on one line and {} on the next, JavaScript automatically adds a semicolon after return. This means the function effectively becomes: return; The { test: 1 } part is never executed. Since return doesn't return anything, the result is undefined. That's why console.log(foo()) shows undefined.
B) Answer In JavaScript, when you write return on one line and {} on the next, JavaScript automatically adds a semicolon after return. This means the function effectively becomes: return; The { test: 1 } part is never executed. Since return doesn't return anything, the result is undefined. That's why console.log(foo()) shows undefined.
Пікірлер