React fundamentals and pitfalls. Mostly from the official doc.
Web workers and service workers are both types of JavaScript workers that run in the background, separate from the main browser thread. However, they serve different purposes and have distinct characteristics.
In many cases such as when dealing with API response in JSON format, working on JavaScript assets embedded on websites, and so on, we keep seeing 13-digit long numbers very frequently and we probably know it is epoch timestamp originating from code like new Date().getTime()
, however, as a human we just can not quickly tell what date and time it represents. There is a convenient website named Epoch Converter that can help convert it to human-readable format easily but most of the time for developers, there are even quicker ways than opening the website, which is by using the interactive shell
that comes with many programming languages.
In Nodejs when dealing with non-text files (e.g. images) IO operations such as transferring via network or reading from disk, there is a big chance to receive the content as stream.Readable
, and before we can process the complete data in memory such as calculating the bytes size or image dimensions, we need save the stream
to buffer
and here are a few ways.
I'm using a perpetual fallback license version of Intellj IDEA Ultimate for daily development but recently I noticed two issues in JavaScript development environment related to ESLint and module alias resolution. Luckily for either issue I managed to find a solution.
As we know the BigInt type is availble in JavaScript as a data type able to represent any arbitrary large integer number, which is a good supplement when a value exceeds what number
could represent. However, when working with applications where you need exchange data with JSON
format, the BigInt
values become a problem because JSON
does not know how to serialize BigInt
values by default, in such cases, one solution is to convert the BigInt
into string
as this post shows.
Following Upgrade socket.io from v2 to v3, this post is about upgrading socket.io
and its associated packages to the latest versions as of when this post is written and the only setting changes seem to be from the redis-adapater
and the way to import client io
this time (for our specific use case).
socket.io and its related libraries such as socket.io-redis-adapter and socket.io-redis-emitter had a few breaking changes in either functions or behaviors since v3 which might cause issues during the v2-to-v3 migration. This post lists what was encountered and how to solve it for specific use cases based on hands-on experience.
Since I find myself writing code more and more in JavaScript nowadays regardless of backend or frontend development, I figure out I should at least give it a look seriously, the first time in more than 10 years, and here are the resources I find useful while diving into this long overlooked programming language.
JavaScript typeof returns and falsy values.
How to dynamically insert js.
How to generate 26 english letters in js.
nodenv is a great tool to manage multiple NodeJS versions and here are some of its commonly used commands summarized for quick reference.
In frontend development sometimes you need to export the data (usually in JSON format) as downloadable csv format, and for those working on ReactJS related web applications, there is a package named react-csv that can save you from breaking the DRY... However, you may also encounter issues when applying this package in some specific scenarios, such as the one I'm writing down soon which involves in data being loaded asyncronously but needed for initial UI rendering.
How to use a jquery plugin to implement floating horizontal scrollbar, which is especially useful for single page application where partial content of the page (i.g. table of data) are large and dynamically updated and you don't want to make use of the browser scrollbar for scrolling the partial content.
A javascript calendar.