JavaScript
31.3K subscribers
1.21K photos
10 videos
33 files
884 links
A resourceful newsletter featuring the latest and most important news, articles, books and updates in the world of #javascript 🚀 Don't miss our Quizzes!

Let's chat: @nairihar
Download Telegram
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🔥21
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);