The Stack Data Structure in JavaScript: Explained and Implemented

A stack is a data structure that comes with certain limitations, contrasting it with arrays. In a stack, we can only add items on top and remove the top item. Think of it like a pile of books, where you can only add books to the top and remove the one on top. This behavior is known as First In, Last Out (FILO). While arrays in JavaScript are already built-in and readily available, we still need to implement stacks ourselves....

The stack I use to run this blog

In this post, I will describe the technologies and tools I use to run my blog. From the site platform to hosting, and even my workflow for posting articles, I’ll cover it all. The site platform This blog is built using Astro, a static site framework. While I previously used Hugo, I found that I enjoy creating user interfaces with JSX more. Astro, like Hugo, generates fast pages that can be easily deployed on platforms like Netlify or Cloudflare Pages....

The startsWith() Method in JavaScript

Introduction In JavaScript, the startsWith() method is used to check if a string starts with a specific substring. By calling startsWith() on a string and providing a substring as a parameter, we can determine whether the string starts with that substring or not. Basic Usage The startsWith() method can be called on any string variable or string literal. It returns a boolean value (true or false), indicating whether the string starts with the specified substring....

The Streams API: Processing Data as it Arrives

Using streams, we can receive a resource from the network or other sources and process it as soon as the first bit arrives. This allows us to immediately work with the resource instead of waiting for it to fully download. What is a stream A common example that demonstrates the benefit of streams is loading a YouTube video. You don’t have to wait for the entire video to load before you can start watching it....

The String endsWith() Method: A Comprehensive Guide

Learn all about the endsWith() method in JavaScript strings and its various functionalities. The endsWith() method in JavaScript allows you to determine whether a string ends with a specified value passed as a parameter. Here are a couple of examples to understand its usage: 'JavaScript'.endsWith('Script') // true 'JavaScript'.endsWith('script') // false In the first example, the endsWith() method returns true because the string ‘JavaScript’ ends with the value ‘Script’. However, in the second example, the method returns false because it performs a case-sensitive comparison, and the value ‘script’ does not match the string’s ending ‘Script’....

The String slice() Method: A Comprehensive Guide

In this blog post, we will explore the JavaScript slice() method for strings. This method allows us to extract a specific portion of a string based on the begin and end positions. One important thing to note is that the original string remains unchanged when using the slice() method. Slicing a String To slice a string, we can use the following syntax: string.slice(begin, end) The begin parameter specifies the starting index of the desired substring....

The String valueOf() Method: Explained in Detail

In JavaScript, the valueOf() method in the String object is used to obtain the string representation of the current String object. It returns the string value of the object. Here is an example of how to use the valueOf() method: const str = new String('Test'); str.valueOf(); //'Test' The valueOf() method returns the same result as the toString() method for strings. Both methods provide the string representation of the object, but they differ in their usage....

The Tailwind Cheat Sheet: Your Ultimate Reference for CSS Properties

I created this cheat sheet to serve as a quick reference for common CSS properties in Tailwind along with their corresponding classes. As a beginner, I often find myself needing to look up these classes in the Tailwind documentation. With this cheat sheet, you’ll have a handy resource at your fingertips to help you build muscle memory and speed up your development process. Here are the CSS properties and classes that I use most frequently:...

The TCP Protocol: A High-Level Overview

TCP, or Transfer Control Protocol, is a fundamental component of the Internet and various other applications such as Email. Originally defined in 1981 through RFC 793, TCP has a longstanding history as one of the pillars of the Internet. TCP operates on top of the Internet Protocol (IP) and serves as the foundation for application-level protocols like HTTP, FTP, IMAP, and many others. Unlike IP and UDP, TCP is a connection-oriented protocol....

The toExponential() Method in JavaScript: Explained

Discover the ins and outs of the JavaScript toExponential() method for numbers. The toExponential() method is quite useful in converting a number into its exponential notation, representing it as a string. Let’s dive into how it works and some examples of its usage. Usage Example: new Number(10).toExponential(); // Output: 1e+1 (equivalent to 1 * 10^1) new Number(21.2).toExponential(); // Output: 2.12e+1 (equivalent to 2.12 * 10^1) In the above examples, we can see how the toExponential() method converts numbers into their exponential equivalent....