Types of tests Unit Tests test very specific, low-level pieces of functionality for example if a function returns the expected value. Integration Tests ensure that the individual pieces of your application work together correctly. For example if a method invocation successfully calls an API which in turn stores a value in the database. Single-service integration […]

This article will demonstrate how to test JavaScript files in NodeJS using the libraries Sinon, Mocha and Chai. Sinon is often installed together with Mocha and Chai, but it is not required.

This article will illustrate the inner workings of JavaScript. It will answer questions like: Is JavaScript single-threaded or multi-threaded? If it really was single threaded, does that mean that JavaScript will run slower than code in multi-threaded languages because it could not take advantage of processing code in parallel? What is the difference between a JavaScript engine and a JavaScript runtime environment?

This article explains how to load JS code asynchronously and when you should defer its execution.

You can use this as a Cheatsheet whenever you do array related operations

Setup Fakes, spies and stubs are created in the default sandbox which needs to be restored after each test to prevent memory leaks. We use a Mocha hook plugin for that: Types of test doubles Type What it does Behavior Pre-programmed behavior Pre-programmed expectations When to use Fake records arguments, return value, the value of […]

Values in a new Set() are unique, they only occur once. You can mySet.add(), mySet.delete(), mySet.clear(). You can check its mySet.size or if it mySet.has(“a”). Avoid that pitfall: If you add objects like in the following example, remember that you create a different object each time: Set values are unique and case sensitive: Convert Array […]

Let’s say you have and want to get rid of item2. How do you do that in JavaScript? Now, newData contains: Or, if you have the key stored as a string in a variable called key: A simple utility function would look like this: Using a list of allowed keys This will make a shallow […]

From latin iterat meaning “repeated” an Iterator provides functionality that allows you to go through (iterate over) each item in a collection of objects.

A Generator is a function that can be paused and resumed at a later time, while having the ability to pass values to and from the function at each pause point.

The basic idea is this: You want to be informed whenever a change (mutation) on a element or its child elements occurs. A change can be a modification of an element’s attributes, its text or if there was a child node appended or removed.

Would you have any clue what an Observable is good for, just from its name? Ok, you can observe something and the ending ‘-able’ might tell you that it lazily waits for you to be observed. Right! But how? By whom? When and why?

let x = []; What is the content of x? If you said an empty array you would be wrong, strictly speaking. The right answer is that x contains a reference (e.g. <#525>) which points to a memory location which contains the value []. let x = 5; What is the content of x here? […]