3 ms·
If that's the case, then wouldn't both "asdf" and "qwer" be printed to the console when executing the following code? function test() { switch (true) {
by richgieg 7y ago
If that's the case, then wouldn't both "asdf" and "qwer" be printed to the console when executing the following code?
function test() {
switch (true) {
case console.log('asdf') === undefined: return 1;
case console.log('qwer') === undefined: return 2;
}
}
test();
- foldr 7y agoHmm, I wrote some similar test code before writing my comment, but only included one 'case'. Indeed, you're right, they're evaluated only as needed.