Asynchronicity in JavaScript

Introduction Asynchronicity is one of the most used and most important aspect of “JavaScript”, so let’s review it. In this post, we’ll start by learning what “v8” and the “events loop” are. Then we’ll talk a bit about callback functions before exploring what promises and observables are. The idea of this post is not to […]

AngularJS adds “unsafe” before links

Recently, I experienced an annoying issue after having upgraded my application from angularjs 1.6 to angularjs 1.7. Consider the following link: View the code on Gist. This is a technique I like to use to simulate a link. Basically, defining the “href” attribute to “javascript:void(0)” along with “ng-click” allowed me to add a link executing […]

How to use Promise instead of $q with AngularJS

Imagine the following AngularJS application: View the code on Gist. The idea behind the “doWork” function of the service is to execute some asynchronous code and return a promise to be able to perform some actions once this code has been completed. For the sake of this example, we just wait for 2 seconds and […]

Generators with ES6

As we saw in the post “Make your ES6 classes iterable“, you can make a class iterable by returning a specific object containing a “next” function used by the “for … of” loop to get the different values. As a reminder, the “next” function returns an object with two properties: “value” defines the current value […]

Make your ES6 classes iterable

If you ever worked with ES6, you probably learned how to use the “for … of” loop and what’s the difference between this loop and the “for … in” one, but what you might not know is how this loop works (my apologize if you do :-)). However, to ensure that everything is crystal clear, […]

Use MutationObserver to spy on the DOM

Have you ever wished that you could “listen to” changes that happen in the DOM? Of course, you have “event handlers” for this, it’s as easy as this: View the code on Gist. However, you can’t catch everything with that. Indeed, what if you want to be notified when the text or an attribute value […]

Create objects on the stack using stackalloc

Imagine we want to create a method that generates an array composed by square values of its indexes and the only parameter we want to pass to this method is the size of the array. A straight-forward approach would be this: View the code on Gist. We could have displayed the values of the array […]

Using TypeScript with Webpack

“TypeScript” is a great language that powers up “JavaScript” and in this post, we’ll see how to ingrate it with “webpack”. If you’re not comfortable with “webpack”, consider reading this post. Start by initializing our web application: yarn init -y Then, install the following packages: yarn add webpack webpack-cli typescript ts-loader -D “webpack” and “webpack-cli” […]

Getting started with RxJS

If you like “promises”, you’ll love “observables”. “Observables” are “something” that you can subscribe to and from which you’ll receive values over time. I’m sure everyone knows what is a “rsa securId” but for those who don’t know, it’s a little device that displays a random access token that changes every X minutes. You can […]