Velocidad de Escape

ESM VS CJS modules

On Twitter I constantly see discussions of this type, about the advantages, disadvantages, why to use them and why not, etc., so I decided to do some research to get out of my ignorance. ## What are ESM and CJS modules? ESM (ECMAScript Modules) and CJS (CommonJS) modules are two different module systems used in JavaScript. They have some key differences in how they are imported, exported, and executed. Here's a brief comparison between the two. ### Syntax - ESM: ECMAScript modules use import and export statements to define dependencies and export values. The import statement is...

JavaScript

Circular dependency and Dependency injection in JavaScript

Very surely we have all faced a problem of circular dependencies at some point in life, it is not very complex to explain and sometimes it is not very difficult to solve. Circular dependencies occur in JavaScript when two or more modules depend on each other in a way that creates a loop. In other words, Module A depends on Module B, and Module B depends on Module A, resulting in a circular reference. Circular dependencies can lead to various issues and make it difficult to understand and maintain code. When the JavaScript runtime encounters circular dependencies, it may not be able to...

JavaScript

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