June 2, 2018JavaScript is regularly claimed to be asynchronous. What does that mean? How does it affect development? How has the approach changed in recent years?
Consider the following code:
result1 = doSomething1();
result2 = doSomething2(result1);Most languages process each line synchronously. The first line runs and return...
April 18, 2018This tutorial covers the basics of JavaScript promises, showing how you can leverage them in your JavaScript development.
The concept of promises is not new to web development. Many of us have already used promises in the form of libraries such as Q, when.js, RSVP.js, etc. Even jQuery has something called a Deferred ob...
September 20, 2017This post was originally posted at Codebrahma.
JavaScript is a single-threaded programming language. That is, when you have code something like this …… the second line doesn’t get executed till the first one gets completed. Mostly this won’t be a problem, since millions of calculations are performed b...
March 23, 2017The debut of Promises in JavaScript has lit the internet on fire—they help developers break out of callback hell and solve a lot of problems that have plagued the asynchronous code of JavaScript programmers everywhere. Promises are far from flawless, though. They still require callbacks, can still be messy in complex...
January 31, 2017Mariko Kosaka with an elaborate and wonderful metaphor.
What is a Promise in JavaScript? It’s like if you go to a restaurant and order a burger and a shake. The restaurant needs to prepare your food, so after you pay, you get a tray with a buzzer on it. The tray is the Promise.
Direct Link to Article — Perm...
August 16, 2016You can’t get far as a JavaScript programmer without learning about functions and objects, and when used together, they are the building blocks we need to get started with a powerful object paradigm called composition. Today we’ll look at some idiomatic patterns for using factory functions to compose functi...
March 17, 2016For a long time, JavaScript developers have used callback functions to perform several tasks. A very common example is to add a callback via the addEventListener() function to execute various operations when an event, such as click or keypress, is fired. Callback functions are simple and get the job done for simple cas...
November 12, 2015Let’s suppose you’d like to let the visitors of your website make a video recording or take a picture of their face. How can you explain to them how close they’re supposed to sit to the camera? You could write lengthy instructions, but you know that today almost nobody reads the instructions. Probably, a ...
September 11, 2015The topic of this article is actually quite specific. Recently, I faced a situation where I needed to preload a lot of images in parallel. With the given constraints, it ended up being more challenging than first expected, and I certainly learnt a lot along the journey. But first, let me describe the situation shortly ...
September 10, 2015Promises are becoming a common part of JavaScript code. The native Promise object is already supported by all the major browsers including Chrome, Firefox, and Safari.
Despite making asynchronous code simpler, dealing with promises in unit tests is a hassle. You need to wire your test’s assertions into the callbacks ...
Recent Comments