3 ms·
To be pedantic the assignment returns null (always returns the rvalue[1]), it's the const statement that produces undefined[2] [1] https://tc39.es/ecma262/mult
by femto113 5y ago
To be pedantic the assignment returns null (always returns the rvalue[1]), it's the const statement that produces undefined[2]
[1] https://tc39.es/ecma262/multipage/ecmascript-language-statements-and-declarations.html#sec-let-and-const-declarations-runtime-semantics-evaluation https://tc39.es/ecma262/multipage/ecmascript-language-statem...
[2] https://tc39.es/ecma262/multipage/ecmascript-language-statements-and-declarations.html#sec-let-and-const-declarations-runtime-semantics-evaluation https://tc39.es/ecma262/multipage/ecmascript-language-statem...
- cipherboy 5y agoAnd to be even more pedantic, the function works because it is applied on an event listener... When null[1] is evaluated (in the right side of the || of the conditional), it produces a TypeError... which in effect (due to no catch and evaluation continuing in a parent/event-driven scope) is essentially equivalent to an empty return in this specific context. What fun! :-) Edit: apparently as also mentioned https://news.ycombinator.com/item?id=30268412 https://news.ycombinator.com/item?id=30268412