A Guide to JavaScript Template Literals

Introduced in ES2015 (aka ES6), Template Literals offer a new and improved way to declare strings in JavaScript. In addition to providing a simple and concise syntax, Template Literals also come with a range of powerful features that make them a popular choice among developers. This guide will cover the following topics: Introduction to Template Literals Multiline strings Interpolation Template tags Introduction to Template Literals Template Literals are a feature introduced in ES2015/ES6 that allow you to work with strings in a more flexible and efficient way compared to traditional single or double quoted strings....

A Tutorial on JavaScript Arrow Functions

JavaScript Arrow Functions, introduced in ES6/ECMAScript 2015, have had a significant impact on modern JavaScript code. They offer a shorter and more concise syntax compared to regular functions, making them widely used in modern codebases. In this tutorial, we will explore the features and benefits of arrow functions. Syntax and Usage Arrow functions provide a simpler syntax for writing functions. Instead of using the function keyword, you can define an arrow function using the => notation....

How I Overcame JavaScript Fatigue and Embraced the Ecosystem

A Quest to Tackle JavaScript Fatigue For the longest time, I dreaded working with JavaScript. The overwhelming changes in the JavaScript ecosystem caused me to experience what is known as “JavaScript Fatigue.” This feeling persisted for years until one day, everything changed. Finding Love for JavaScript My introduction to JavaScript dates back to the nineties when document.write statements filled my books. Around 2012-2013, the impending arrival of ES6 (ECMAScript 2015) flooded discussions everywhere....

How to Get the Index of an Iteration in a for-of Loop in JavaScript

In JavaScript, a for-of loop is a powerful feature introduced in ES6 that allows you to iterate over an array effortlessly. However, by default, it does not provide a straightforward way to access the index of each iteration. But worry not! In this blog post, I will show you how to easily obtain the index of an iteration using a combination of the destructuring syntax and the entries() method. Let’s dive in!...

How to Set Default Parameter Values in JavaScript

Learn how to add default parameter values to your JavaScript functions for improved flexibility and ease of use. Default parameter values were introduced in ES6 in 2015 and have become widely implemented in modern browsers. Let’s start with a simple example of a function called doSomething that accepts a parameter param1: const doSomething = (param1) => { } To add a default value for param1 in case the function is invoked without specifying a parameter, you can modify the function like this:...

JavaScript Function Parameters

Learn the basics of JavaScript Function Parameters. A function in JavaScript can accept one or more parameters. Let’s look at some examples: const doSomething = () => { //do something } const doSomethingElse = (foo) => { //do something } const doSomethingElseAgain = (foo, bar) => { //do something } Starting from ES6/ES2015, functions can have default values for their parameters. Here’s an example: const doSomething = (foo = 1, bar = 'hey') => { //do something } This allows you to call the function without specifying all the parameters:...

The Map JavaScript Data Structure

Discover the Map data structure introduced in ES6 to associate data with keys. Before its introduction, people generally used objects as maps, by associating some object or value to a specific key value. What is a Map A Map data structure allows you to associate data to a key. Before ES6 ECMAScript 6 (also called ES2015) introduced the Map data structure to the JavaScript world, along with Set. Before its introduction, people generally used objects as maps, by associating some object or value to a specific key value:...

Working with Unicode in JavaScript: A Comprehensive Guide

In this article, we will explore how to effectively work with Unicode in JavaScript. We will cover topics such as Unicode encoding of source files, how JavaScript uses Unicode internally, using Unicode characters in a string, normalization, emojis, getting the proper length of a string, ES6 Unicode code point escapes, and encoding ASCII characters. Unicode Encoding of Source Files When working with JavaScript, it’s important to specify the Unicode encoding of your source files, especially if you plan to use non-ASCII characters....