console.log Returns Nothing
luljs still worksNest console.log inside itself and watch the undefineds stack up.
In 2026: Still works. console.log prints its arguments and returns undefined. So the innermost call prints "lol", and every call wrapped around it prints the undefined that the call inside it returned. Four logs, one real message, three undefineds. Open the browser console to see it.
Where it came from: console.log is defined to return undefined by the WHATWG console standard, so nesting it prints the return value of each inner call. WHATWG ↗
<script>
// Open the browser console to see the output stack up.
console.log(console.log(console.log(console.log("lol"))));
document.write("<p>Open the browser console. It prints:</p>");
document.write("<pre>lol\nundefined\nundefined\nundefined</pre>");
document.write("<p><code>console.log</code> returns <b>undefined</b>, which the call around it then logs.</p>");
</script>