sm

Tagged "JavaScript"

  1. in Articles
    Simplify event delegation with the Element.closest method
    Event delegation is a useful pattern for managing descendant interactions and Element.closest helps with simple and robust code
  2. in Articles
    Thoughts on Web Speech API
    Browser native text-to-speech is neat, but it lacks the polish that most users expect
  3. in Articles
    See what object properties are accessed in JavaScript
    JavaScript's Proxy object can be used to watch an object and respond whenever any of its properties are accessed or reassigned
  4. in Articles
    Remove duplicates from an array in JavaScript
    Using sets to de-dupe arrays of primitive and object-like values
  5. in Articles
    A quick comparison of JavaScript and Go executables
    Go is the superior for executables based file size and execution time, but Bun and Deno offer a competitive option for developers familiar with the JavaScript ecosystem
  6. in Articles
    Compairing Objects, Maps, and WeakMaps for lookup tables in JavaScript
    You could use an Object, but Maps are probably best for lookup tables and WeakMaps are useful for memory performance
  7. in Articles
    What is nullish in JavaScript?
    Nullish values are null and undefined, and it's important to thing of them separately from falsy values
  8. in Articles
    Listen for class change in JavaScript
    There isn’t an event for class list changes, but you can write a function that listens for class changes on an element with the MutationObserver API
  9. in Articles
    Valid JavaScript variable names
    Mathias Bynen has a handy tool for determining what characters are allowed in a JS variable name
  10. in Articles
    Be careful parsing formatted numbers in JavaScript
    JavaScript's parseInt, parseFloat, and Number constructors struggle with comma-separated number strings.
  11. in Articles
    Node.js is great for scripting
    Node.js and JavaScript are a great option for scripting for the language features and the large ecosystem. Oh, and it's pretty fast too!
  12. in Articles
    How to replace Math.random with crypto in JavaScript
    A drop-in replacement for Math.random that generates cryptographically strong random values
  13. in Articles
    Make a web component
    How to make a custom web component with only a few lines of code
  14. in Articles
    Get innerHTML of Enzyme wrapper
    Writing a little helper function to grab the HTML of all children of a shallow wrapper in Enzyme
  15. in Articles
    Use remark to covert markdown into HTML
    The missing "hello world" example to get up and running with remark
  16. in Articles
    Count class methods in JavaScript
    Although JS treats them like object, finding the methods of a class programmatically is trickier than I thought.
  17. in Articles
    Read URL search parameters with JavaScript
    How to use URLSearchParams to parse any search parameters string like window.location.search
  18. in Articles
    Increase the playback speed on any audio or video online
    Since audio and video are native HTML elements, you can change the playing speed with a quick console script
  19. in Articles
    TypeScript without TypeScript
    TypeScript provides valuable features but complicate the development process. What are some alternatives that provide the features without the headache?
  20. in Articles
    Make a POST request with fetch
    A sample POST with fetch for those of us who can never remember how.
  21. in Articles
    Remove an item at a given index in JavaScript
    Sidestep slicing and splicing and use Array's filter method for a no-hassle solution.
  22. in Articles
    Await multiple promises in JavaScript
    By calling your asynchronous functions before awaiting, you can save valuable time in your JavaScript programs
  23. in Articles
    Read a json file in Deno
    How to use Deno's standard library to read and parse data from a json file.
  24. in Articles
    Read a json file in Node.js
    How to use Node.js's file system to read and parse data from a json file.
  25. in Articles
    How to get the browser and version in JavaScript
    A brief journey into the dangerous world of user agent sniffing
  26. in Articles
    How to check npm scripts in current directory
    Writing a script to read the package.json for you
  27. in Articles
    How to remove duplicates from an object array?
    Not as easy as we'd like it, but not as hard as it could be
  28. in Articles
    What default parameters do (and don't do)
    Correcting my mental model
  29. in Articles
    Add event listener for class change
    How to create a custom event listener for class names using the MutationObserver API
  30. in Articles
    Filter out premium Medium articles
    Using a console script to alter the content on a webpage
  31. in Articles
    JS Basics: Generate a random number
    Using JavaScript's Math object to generate random numbers
  32. in Articles
    JS Basics: Ternary Operator
    Demystifying the inline if statement