JavaScript Tutorials

  • By
    How to Internationalize Numbers with JavaScript

    Presenting numbers in a readable format takes many forms, from visual charts to simply adding punctuation. Those punctuation, however, are different based on internationalization. Some countries use , for decimal, while others use .. Worried about having to code for all this madness?

  • By
    How to Extend Prototypes with JavaScript

    One of the ideological sticking points of the first JavaScript framework was was extending prototypes vs. wrapping functions. Frameworks like MooTools and Prototype extended prototypes while jQuery and other smaller frameworks did not. Each had their benefits, but ultimately all these years later I still...

  • By
    How to Use window.crypto in Node.js

    I've been writing a bunch of jest tests recently for libraries that use the underlying window.crypto methods like getRandomValues() and window.crypto.subtle key management methods. One problem I run into is that the window.crypto object isn't available, so I need to shim it.To use the window.crypto...

  • By
    Convert Fahrenheit to Celsius with JavaScript

    The United States is one of the last bodies that refuses to implement the Celsius temperature standard. Why? Because we're arrogant and feel like we don't need to change. With that said, if you code for users outside the US, it's important to provide localized weather...

  • By
    Detect System Theme Preference Change Using JavaScript

    JavaScript and CSS allow users to detect the user theme preference with CSS' prefers-color-scheme media query. It's standard these days to use that preference to show the dark or light theme on a given website. But what if the user changes their preference...

  • By
    How to Use Storage in Web Extensions

    Working on a web extension is an interesting experience -- you get to taste web while working with special extension APIs. One such API is storage -- the web extension flavor of persistence. Let's explore how you can use session and local storage within...

  • By
    Skip or Only Run a Test with JavaScript Mocha

    Whenever I start to feel anxiety about a big change I'm making, I start writing more unit tests. I'll write down my fear and then write a test that attacks, and eventually relaxes, that fear. There are two actions that I've been frequently using...

  • By
    Monitor Events and Function Calls via Console

    Despite having worked on the very complex Firefox for a number of years, I'll always love plain old console.log debugging. Logging can provide an audit trail as events happen and text you can share with others. Did you know that chrome provides monitorEvents and...

  • By
    Specify Node Versions with .nvmrc

    I've heavily promoted nvm, a Node.js version manager, over the years. Having a tool to manage multiple versions of a language interpreter has been so useful, especially due to the complexity of Node.js package management.One tip I like to give new developers is adding a...

  • By
    How to Inject a Global with Web Extensions in Manifest V3

    For those of you not familiar with the world of web extension development, a storm is brewing with Chrome. Google will stop support for manifest version 2, which is what the vast majority of web extensions use. Manifest version 3 sees many changes but the largest...