Velocidad de Escape

Stop using If else and Switch statements

This is quite difficult to explain, because I don't completely disagree with the use of if-else. The main reason for the existence of the switch statement was to avoid if-else structure in certain cases. Sometimes we have more than 1 comparison to do, since there could be many cases to evaluate, and at this point these statements become something tremendously verbose. ## Using if-else ```js function rating(rating) { if (rating === "five") { return "you are a super genius" } else if (rating === "four") { return "you are very smart" } else if (rating === "three") { return...

JavaScript

Redux VS Redux Toolkit

I've been working with Vue and Vuex for over 16 months, but React has always been the library of my loves, so I decided to start a short project with React, Redux and TypeScript to refresh my knowledge. _I have never been in favor of using TS on the frontend, it seems unnecessary to me, but hey, it is the subject of another conversation._ I decided to create my project using _Create React App_ using the Redux-TypeScript template, but I came across unexpected news; Redux has changed dramatically since I last used it. I had to start reading the official documentation again, luckily I came...

React

Fluent Interfaces in JavaScript

A couple of days ago, I had a technical interview and one of the exercises was OOP and **Fluent Interface**, I had seen its use a couple of times, but I had never had to develop anything similar. ## Fluent Interface The Fluent Interface is often referred to as *Method Chaining*, *Fluent API* or *jQuery Style*. A fluent interface is an object-oriented API whose design relies extensively on method chaining. Its goal is to increase code legibility by creating a domain-specific language (DSL). The term was coined in 2005 by Eric Evans and Martin Fowler <sup>[1]</sup>. If you ever worked with...

JavaScript

Javascript Proxy, a gentle introduction

A couple of months ago I was asking to my colleagues if they knew what JavaScript Proxies were for, I think that none had used it yet, so I decided to read a little more about its use. Proxy object was a new feature that was introduced in ES6. **They allow you to intercept and customize operations performed on objects. E.g., function invocation, assignment, property lookup, enumeration, etc. We use proxies for blocking direct access to the target function or object.** JavaScript Proxy is too powerful a tool, which if used correctly could bring us a lot of excellent benefits. ## Simple...

JavaScript