Archive: October 2026

  • Note - Posted on

    What’s the value of b after the following code runs?

    let a = 10;
    let b = a;
    a = 0;

    It’s 10. Even though I had gotten it right, I couldn’t have explained why.

    Dan Abramov and Maggie Appleton’s course, Just JavaScript, helped me develop a better mental model of how it works and now it’s free to access for everyone.

  • Inline rendering with document.currentScript

    Today I learned about document.currentScript thanks to Lean Rada.

    Using document.currentScript with the replaceWith() method, the footer can update itself and fix one of the most common problems on the web: a stale copyright year.

    <footer>
    	©
    	<noscript>2026</noscript>
    	<script>
    		document.currentScript.replaceWith(new Date().getFullYear());
    	</script>
    </footer>

    As mentioned on MDN, document.currentScript returns the <script> element whose script is currently being processed and isn’t a JavaScript module.

    So when the above script runs, the document.currentScript returns the script element. However, a script can only change the page when it explicitly touches the DOM, so we use the replaceWith() method. It swaps the returned script element for the year.

    Before I learned about document.currentScript, I would have used a templating language and set up a cron job to rebuild the site every 1st Jan. Or I would have used the textContent property, which needs an id or a selector to find the element. document.currentScript is much more convenient since it already knows where it is.

  • You’ll miss publishers when they’re gone - Andy Bell

    Let me make it clear: without people at the top of their game sharing their experience and knowledge — regardless of whatever “game changing” technology is in place — we are pulling up the ladders and committing our industry to stagnation and death. We’ve already fucked it up over the last few years for junior developers by instead of investing in them, playing the slot machines (also known as LLMs) to — you guessed it — make the money number go up, but there’s still hope for recovery.