Question 16
Back to Exercise
What does the following JavaScript code print (console output, as in Node.js)?
const f = () => (console.log("side effect"), 42);
console.log(f());
- A 42 side effect
- B 42
- C side effect 42 Correct
- D undefined
Correct Answer: Option C
The comma operator evaluates the log first and then returns 42, which the outer console.log prints.
Discussion & Comments 0
Share your method, a shortcut, or ask about a step you didn't follow.
No comments yet. Be the first to share your solution!