JavaScript

Asynchronous array operations in ES7 JavaScript async/await functions

A glaring problem with the most excellent async/await feature in JavaScript is all the existing coding structures that only work with synchronous code. In an async/await function it's trivially easy to write a simple "for" loop that contains whatever async/await calls you want. But as soon as you try "Array.forEach" with an async callback function it will fail miserably. That's because this function, like so many existing interfaces which take a callback function, assumes the callback is synchronous.

Useful reading to understand the Promises, Generators and the async/await feature for Node.js/JavaScript

The long-awaited async/await feature for JavaScript promises to make our lives much easier. Instead of asynchronous JavaScript programming being tricky and error-prone, with async/await our code will look like regular synchronous code we write in other languages, but will accommodate asynchronous code execution while retaining the single-threaded nature of JavaScript.

Asynchronous Node.js/JavaScript programming with Generators and async/await

The advent of async/await for Node.js - Node.js v7 has now arrived: The long-awaited day has arrived when we can begin to use async/await in JavaScript without jumping through crazy hoops. In Node.js v7 we just run our code with a command-line option, and voila we can use async functions.

You can joyfully parse and manipulate URL's in browser-based JavaScript

URL's are not strings, but are a data structure that's represented as a string. How do you easily and reliably manipulate a URL string programmatically? Do you use regular expressions or other kinds of string manipulations? Given all the ways to encode data in a URL, how do you ensure it remains syntactically correct while doing string manipulation? Manipulating URL's with regular expressions is rather difficult because of the format and nature of a URL.

Avoid tearing your hair out on variable values in deeply nested JavaScript/Node.js callback chains

JavaScript, and hence Node.js, supports a useful model for variable scoping and callback functions where the available variables build up as the code nests. It's very convenient because your code doesn't have to pass values through function parameters to code in an in-line callback function. But it's possible for a variable to not have the expected value by the time the callback function executes. When that's the case, it's tempting to start tearing your hair out in frustration screaming about the variable's value is incorrect.

JavaScript doesn't tell you the Date object is bad, here's how to figure that out before crashing your program

In JavaScript, creating a Date object from a string is real convenient ("var foo = new Date(dateString)"), but what if dateString has a bad format? How will your code know about this? The Date object doesn't have a getter to tell you the date is bad.

Viewer.js, a powerful pure-JavaScript document viewer to simplify your visitors document experience

I hate the typical user experience around viewing and distributing PDF files (or other document formats). Usually we're forced to download the file to our local computer, then view it using a separate viewer. It litters the Downloads directory with old files we've downloaded, and it's somewhat jarring to find yourself suddenly having to navigate to a separate viewer application. Further, an external viewer probably doesn't work well on a mobile device where the operating paradigm is quite different from desktop computers.

Review: The Past, Present and Future of JavaScript (Axel Rauschmayer)

You may have heard that the ECMAScript committee (that oversee's the standards for JavaScript) are working on the next version of the language.

Pages