Velocidad de Escape

Memory Management in JavaScript and Garbage Collector

<a class="hover:no-underline text-blue underline" href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Memory_management" target="_blank" rel="noreferrer">Memory management</a> > Low-level languages like C, have manual memory management primitives such as `malloc()` and `free()`. In contrast, JavaScript automatically allocates memory when objects are created and frees it when they are not used anymore (garbage collection). This automaticity is a potential source of confusion: it can give developers the false impression that they don't need to worry about memory management. The last...

JavaScript

Why in JS typeof array and null is object?

First at all, let's recap ## Data types in JavaScript | Type | `typeof` return value | |-----------|---------------------| | Null | "object" | | Undefined | "undefined" | | Boolean | "boolean" | | Number | "number" | | BigInt | "BigInt" | | String | "string" | | Symbol | "symbol" | | Object | "object" | _The information in this table may vary depending on the author_ Based on this table, several questions already arise if you are a beginner in JavaScript, - Why `typeof null`...

JavaScript

Using AbortController in React

The use of <a class="hover:no-underline text-blue underline" href="https://developer.mozilla.org/en-US/docs/Web/API/AbortController" target="_blank" rel="noreferrer">AbortController</a> is helpful in situations where a network request needs to be canceled before it completes, such as when the user navigates to a different page or when a request needs to be interrupted that is taking too long to complete. `AbortController` provides a more flexible and precise way to cancel network requests. By creating an instance of `AbortController`, a **signal** can be generated that can be passed to a...

React

Built-in error objects in JavaScript

This morning I was improving a bit my blog, and I found this piece of code, this is simply a validation that I am doing on a component that I create for Astro: ```js if (typeof text !== "string") { throw new Error("text must be a string") } if (typeof maxLength !== "number") { throw new Error("maxLength must be a number") } if (typeof addEllipsis !== "boolean") { throw new Error("addEllipsis must be a boolean") } ``` `throw new Error` is not incorrect, but it is generic, the `TypeError` object is more specific and is commonly used for errors that occur when a value is not of the...

JavaScript