Category: JavaScript

  • Bold text without jumping: Text shadows instead of font-weight

    Bold text without jumping: Text shadows instead of font-weight

    You have seen this effect, even if you rarely notice it consciously: you hover over a navigation menu, the item turns bold, and the whole menu twitches. The neighbours shift a few pixels to the side, a line suddenly wraps differently, a right-aligned number hops. It is only a detail, but it makes a page…

  • NodeJS: async.queue does not display error messages by default

    NodeJS: async.queue does not display error messages by default

    Currently, I’m creating a custom web crawler and the easiest method to implement concurrency is to use the npm package “async“. While coding, I came across the problem, that the program wasn’t working correctly, but the terminal didn’t display any errors. So I tested the queued function outside of async, and it threw an error…

  • Javascript – Rounding floating point numbers

    Javascript – Rounding floating point numbers

    There are six different functions in JavaScript’s Math library for rounding floating point numbers: What is the difference between these functions? abs() abs() is the absolute value of a number. Mathematically speaking, it is the distance of a number from zero. As a distance cannot be negative, the absolute value is always the positive value…

  • Weekend project: Jump to Header

    Weekend project: Jump to Header

    Some time ago, I came across the browser “Nyxt“. I found one feature particularly practical, namely the option of displaying the headings (<H1> to <H6>) in a side panel. Chrome also contains a side panel for some time now. The above feature could be displayed in this. A quick search in the Webstore revealed that…

  • The modern way of checking radio groups

    The modern way of checking radio groups

    Checking radio groups in JavaScript has always been a bit tricky because you can only check if a particular radio button is selected, not the whole group at once. Wow, that looks archaic. There must be a better way using the new ES6 features, and there is! As of ES2015, NodeList contains a forEach method().…

  • How-to split a number into equal chunks

    How-to split a number into equal chunks

    The other day I had to iterate over a large number of items but to avoid a timeout I could only compute a certain amount at a time. So I had to split the number into equal chunks and a remainder. Here’s an easy way to determine the chunk size: The code return the following…

  • Javascript – Swap classes of an HTML element

    Recently I came across the problem, that I had to programmatically change a div’s color from red to green. Sounds simple and it’s actually quite simple if you know your JavaScript.