Category: Raw Javascript

Introduction to the Fetch API

In this article, we’ll learn what the new Fetch API looks like, what problems it solves, and the most practical way to retrieve remote data inside your web page using the fetch() function. For years, XMLHttpRequest has been web developers’ trusted sidekick. Whether directly or under the hood, XMLHttpRequest has ena...

An Overview of JavaScript Promises

This 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...

Understanding ES6 Modules

This article explores ES6 modules, showing how they can be used today with the help of a transpiler. Almost every language has a concept of modules — a way to include functionality declared in one file within another. Typically, a developer creates an encapsulated library of code responsible for handling related task...

ES6 Generators and Iterators: a Developer’s Guide

ES6 brought a number of new features to the JavaScript language. Two of these features, generators and iterators, have substantially changed how we write specific functions in more complex front-end code. While they do play nicely with each other, what they actually do can be a little confusing, so let’s check them o...

ES6 in Action: let and const

In this tutorial, I’ll introduce let and const, two new keywords added to JavaScript with the arrival of ES6. They enhance JavaScript by providing a way to define block-scope variables and constants. This article is one of many covering new features of JavaScript introduced with ES6, including Map and WeakMap, Se...

ES6 in Action: New Array.* and Array.prototype.* Methods

In this article, we’ll discuss most of the new methods available in ES6 that work with the Array type, using Array.* and Array.prototype.*. When discussing them, I’ll write Array.method() when I describe a “class” method and Array.prototype.method() when I outline an “instance” method. We’ll also see some...

ES6 in Action: New String Methods — String.prototype.*

In my previous article on ES6 array methods, I introduced the new methods available in ECMAScript 6 that work with the Array type. In this tutorial, you’ll learn about new ES6 methods that work with strings: String.prototype.* We’ll develop several examples, and mention the polyfills available for them. Rem...

ES6 in Action: New Number Methods

This article covers new and improved number methods in ES6 (ECMAScript 6). It’s part of a series about the new features of ES6, in which we’ve also discussed new methods available for the String and Array data types, but also new types of data like Map and WeakMap. I’ll introduce you to the new methods and consta...

Game AI: The Bots Strike Back!

The following is a short extract taken from our new book, HTML5 Games: Novice to Ninja, written by Earle Castledine. Access to the book is included with SitePoint Premium membership, or you can grab a copy in stores worldwide. You can check out a free sample of the first chapter here. We have all the tools at our dispo...

JavaScript Functions That Define and Rewrite Themselves

The following is a short extract from our new book, JavaScript: Novice to Ninja, 2nd Edition, written by Darren Jones. It’s the ultimate beginner’s guide to JavaScript. SitePoint Premium members get access with their membership, or you can buy a copy in stores worldwide. The dynamic nature of JavaScript me...