4 ms·
That’s not true. If it appears true it’s because you’re using a repl that treats the first part as a separate statement and returns the value of the second part
by langguage 2y ago
That’s not true. If it appears true it’s because you’re using a repl that treats the first part as a separate statement and returns the value of the second part as the most recent statement, but there’s literally nowhere you can encounter the behaviour you described in a JavaScript program
- johnfn 2y agoIt is true. If you paste it into TS on its own line, even inside a function, TS will flag 'a' as an unused label.
- langguage 2y agoThat’s not the claim that was made. That code can not be evaluated to produce that value by any rules of the language. It can only be evaluated to produce that result by a repl which is parsing it as statements and then evaluating the most recent statement, in a non-standard way, but in the language itself two consecutive statements do not have a defined evaluation, and in any context where it is being evaluated it would gramatically need to be parsed as a single expression instead. If that’s not correct you can provide a counter example
- DangitBobby 2y agoconsole.log(eval('{a:1}["a"]'))