Pages about JavaScript – page 1 of 2

Signing in to Azure Artifacts using npm on Mac

Microsoft Azure Artifacts uses your email address for logging in. If you are on Linux or a Mac, that can make it difficult to sign in to its npm registry using npm-login or npm-adduser. Here I show you how to configure your .npmrc file manually to avoid the problem.

Allowing "at" characters in npm usernames

Some npm registries use email addresses for usernames. That is incompatible with the npm commandline tools, like npm-login and npm-adduser. I found out how to configure the .npmrc file manually to avoid the problem.

Emulating ZX Spectrum graphics in JavaScript

I'm using EcmaScript 6 Proxy objects to keep track of dirty blocks in emulated ZX Spectrum video RAM in a browser. I describe how the ZX Spectrum video RAM works, and implement an emulator using modern JavaScript.

"Hello, World!" in JavaScript

A "Hello, World!" program in JavaScript can be written by calling the log method of the console object to send the "Hello, World!" string to the standard output stream, or the developer console in a web browser.

Overriding console.log in JavaScript

JavaScript is a dynamic language, where even functions are just object variables, pointing to some runnable code. This makes it possible to replace default implementations with your own implementations. However, if you are not careful, it can lead to problems that are hard to debug.

JavaScript countdown using localStorage

Using localStorage, it's possible to implement a countdown clock in JavaScript that survives a reboot of the user's computer. However, it's not possible to know when the user clears their localStorage contents.

Formatting a truncated float in JavaScript

By combining multiplication, division, and Math.floor(), it is possible to truncate a floating point number to a chosen number of decimals in JavaScript. Here, I explain every step of the way, and show how it's done in a one-liner.

JavaScript Csv file generator, part 3 of 3

The final touches are added to my CSV file generation framework in JavaScript. Escaping the separator and quotation marks are done, and the framework is finished!

JavaScript Csv file generator, part 2 of 3

Here I implement the basics of a simple CSV file generation framework in JavaScript.

JavaScript Csv file generator, part 1 of 3

To implement a CSV file generation framework in JavaScript, I start with imagining how I would like to use the framework. From there, I create unit tests to get me started.

JavaScript unit test framework, part 4 of 4

In the last part of this series, I add a pluggable output system to my JavaScript unit test framework, so that test results can be displayed nicely, or sent to a server for logging.

JavaScript unit test framework, part 3 of 4

Any mature unit test framework contains helper methods for validating or asserting requirements. In this part, I start adding some object-oriented test functions.