What is the output?
Anonymous Quiz
38%
ReferenceError string hoisted
31%
ReferenceError undefined hoisted
26%
undefined string hoisted
5%
TypeError string hoisted
🔥3❤1
Did you know JavaScript supports a third type of comment (beyond // and /* */)? 😉 Mat Marquis shows off hashbang comments in a short YouTube video. And yes, they're in the language spec!
Please open Telegram to view this post
VIEW IN TELEGRAM
🤔4🔥2❤1
CHALLENGE
const obj = { a: { b: null }, getVal: null };
let counter = 0;
function sideEffect() {
counter++;
return counter;
}
const result = obj?.a?.b?.[sideEffect()] ?? 'default1';
const result2 = obj.getVal?.(sideEffect()) ?? 'default2';
const result3 = obj?.a?.c?.d ?? sideEffect();
console.log(result, result2, result3, counter);What is the output?
Anonymous Quiz
34%
default1 default2 undefined 0
29%
1 2 1 1
27%
default1 default2 1 1
10%
default1 default2 default3 0
🔥2