Introducción a JavaScript
¿Por qué aprender JavaScript?
¡Hola Mundo! en Mac
¡Hola Mundo! en Windows
Anatomía de una variable
Tipos de datos en JavaScript
Creación de strings
Operadores aritméticos
Conversión de tipos: Type Casting y Coerción
Conversión de tipos explícita e implícita
Estructuras de Control y Lógica
Operadores de comparación
Operadores lógicos
Ejecución condicional: if
Ejercicio: Adivina el número
Ejecución condicional: switch
Loop: for
Loop: for of
Loop: for in
Loop: while
Loop: do while
Funciones y This
Anatomía de una función
Funciones vs Métodos
Funciones puras e impuras
Arrow function y enlace léxico
Contextos de ejecución y scope chain
¿Qué es Closure?
Preguntas a Desarrolladores Senior: ¿Por qué aprender Desarrollo Web?
Manipulación de Arrays
Introducción a Arrays
Mutabilidad e inmutabilidad de Arrays
Modificación básica del final con push( ), pop( )
Iteración con map( ) y forEach( )
Filtrado y reducción con filter( ) y reduce( )
Búsqueda de elementos con find( ) y findIndex( )
Crear copias con slice( )
Spread operator: casos de uso
Programación Orientada a Objetos
Anatomía de un Objeto
Trabajando con objetos en JavaScript
Función constructora
¿Qué es una clase?
Prototipos y herencias
Herencia en la práctica
Prototipos en la práctica
this en JavaScript
Proyecto: Crea una red social
Proyecto: Crea una red social parte 2
Asincronía en JavaScript
¿Cómo funciona el JavaScript Engine?
Promesas en JavaScript
Usando Async y await en JavaScript
For await of
¿Cómo funciona la web?
¿Cómo funciona HTTP?
Método GET en JavaScript
Método POST en JavaScript
Método DELETE en JavaScript
Importancia del id en el método DELETE
ECMAScript 6 y tus siguientes pasos
You don't have access to this class
Keep learning! Join and start boosting your career
When programming, one of the fundamental concepts to master are conditional structures, also known as control structures. These structures allow us to decide which part of our code will be executed based on certain conditions. In JavaScript, the most basic conditional structure is the if
statement, which allows us to execute a block of code only if a certain condition is true.
To use the if
structure, operators must be used to help us create logical conditions that can be evaluated as true or false. These operators can be comparison operators such as ==
, ===
, !=
, !==
or relation operators such as <,
>
, <=
, >=
.
if
structure used?Here we explain how the if
structure works with practical examples:
let name = "Diego";
if (name === "Diego") { console.log("Hello Diego");}
In this example, we have defined a variable name
and compared it using the strict comparison operator ===
. If name
equals "Diego", then the code block inside the if
will be executed.
else
and how does it work?The else
is used when we want a different code block to be executed if the if
condition is not met. It serves as a default instruction in case none of the above conditions are true.
let name = "Nico";
if (name === "Diego") { console.log("Hello Diego");} else { console.log("Name not found");}
In the above example, if the variable name
is not equal to "Diego", the code block inside the else
will be executed, displaying "Name not found".
else if
for multiple conditions?To evaluate multiple conditions, you can extend the else if
structure. This allows us to test multiple conditions in series.
let name = "Nico";
if (name === "Diego") { console.log("Hello Diego");} else if (name === "Nico") { console.log("Hello Nico");} else { console.log("Name not found");}
Here, it first checks if name
is equal to "Diego". If it is not, the next else if
condition for "Nico" is checked, and in case none of the above conditions is true, the block inside the else
is executed.
Conditional structures are essential because they allow us to make decisions within the code based on dynamic conditions. They facilitate the creation of more interactive and adaptive programs, where the execution flow can vary dramatically depending on the input data. Thanks to the ability to evaluate conditions, we can create robust and flexible code that responds according to different scenarios, which is crucial for application development and process automation.
In addition, it is important to mention that, by using these structures correctly, we can make our code more readable and reduce the possibility of logical errors, thus improving maintainability and long-term code evolution.
Never stop exploring and learning about these fundamental functions in programming! Conditional structures are the basis to start building more complex and detailed logic into your projects.
Contributions 38
Questions 1
Want to see more contributions, questions and answers from the community?