The JavaScript String match() Method

Learn about the match() method in JavaScript for strings. The match() method is used to search for a specified regular expression pattern inside a string. It returns an array of all the matches found or null if no matches are found. Here are some examples of using the match() method: Example 1: 'Hi Flavio'.match(/avio/) // Output: Array [ 'avio' ] Example 2: 'Test 123123329'.match(/\d+/) // Output: Array [ "123123329" ] Example 3:...

The JavaScript toLocaleString() Method: A Guide

In JavaScript, the toLocaleString() method allows you to format a number based on a specific locale. By default, the method uses US English as the locale. However, you can pass a locale as the first parameter to format the number accordingly. Here’s an example using the default locale: new Number(21.2).toLocaleString(); // 21.2 If we want to format the number for a different locale, we can pass the locale as the first parameter....

The Journey of Becoming a Content Creator: A Personal Account

In this day and age, the term “content creator” is commonly used to describe individuals who work independently on the internet, making a living through various informational and content-related pursuits. While I personally don’t consider myself a content creator per se, I do see myself as a creator of educational products. In 2021, being a blogger and course creator has become my full-time job. So, how did I end up here?...

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

The Node Core Modules: A Comprehensive Overview

Node.js, a popular runtime environment for executing JavaScript code on the server-side, comes with a rich set of core modules. These modules are included in the Node.js installation and provide essential functionalities for building efficient and scalable applications. In this article, we will explore each of these core modules and their key features. Core Modules Provided by Node.js Node.js provides the following core modules: assert: This module offers a set of assertion functions that are useful for testing and validating code....

The Number isFinite() Method: Everything You Need to Know

In JavaScript, the isFinite() method of the Number object is used to determine whether a given value is a finite number. It returns true if the value is indeed finite, and false if it is not. It is important to note that this method will return false for values that are not of the number data type, such as booleans, strings, objects, and arrays. Let’s take a look at some examples to understand this method better:...

The Object assign() Method: A Closer Look

The assign() method is a useful feature introduced in ES2015 for the Object object in JavaScript. It allows you to copy all the enumerable own properties from one or more objects into another object. The primary purpose of assign() is to create a shallow copy of an object. It means that the values of the properties are cloned, but the object references are copied instead of creating new objects. This implies that if you modify a property in the original object, the corresponding property in the copied object will also be modified....

The Object create() Method: A Complete Guide

Learn all about the create() method of the Object object in JavaScript. Introduced in ES5, the create() method is used to create a new object with a specified prototype. Usage To use the create() method, follow this syntax: const newObject = Object.create(prototype); For example: const animal = {}; const dog = Object.create(animal); The newly created object will inherit all the properties of the prototype object. You can also add new properties to the object that the prototype lacked by specifying a second parameter:...

The Object entries() Method: Explained and Utilized

The entries() method of the JavaScript Object object is a powerful tool introduced in ES2017. It allows you to retrieve all the own properties of an object and returns them as an array of [key, value] pairs. Usage To understand how to use the entries() method, let’s consider a simple example. Suppose we have an object called person with the properties name and age: const person = { name: 'Fred', age: 87 } We can use the entries() method on the person object to retrieve an array containing all its properties:...

The Object isFrozen() Method: Explained and Demonstrated

The isFrozen() method in JavaScript can be used to determine whether an object is frozen or not. When an object is frozen, it means that it cannot be modified. This method accepts an object as an argument and returns true if the object is frozen, and false otherwise. Objects are typically frozen using the Object.freeze() function. When an object is frozen, its properties cannot be added, modified, or removed. The isFrozen() method allows you to check the frozen state of an object and make decisions based on that information....