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
The loop for-of
method is a powerful programming tool that allows you to iterate over iterable objects. Although it may seem complicated at first, its application becomes intuitive once you understand how it works and its practical applications. The name "for-of" is already quite descriptive: it's about traversing element by element of a collection. In this content, I will teach you how to use it effectively.
The for-of
is used on iterable objects, such as arrays and strings. These are elements that, by their nature, are arranged in the form of a list that we can traverse or iterate through. Thanks to its structure, the for-of
allows us to execute code repeatedly for each element present in these collections.
To implement a for-of
, you must follow a basic structure:
for
.()
, where a variable representing each element is defined.of
followed by the iterable object you are traversing.{}
to include the block of code to be executed for each element.Here's an example in code:
let basket = ['apple', 'pear', 'orange', 'grape'];
for (let fruit of basket) { console.log(fruit);}
In this case, the for-of
will traverse through each item in the basket
list and print "apple", "pear", "orange" and "grape" in the browser console, one by one.
for-of
is ideal for cases where you want to access values directly, and not indexes as with for-in
.Understanding and using for-of
is a valuable skill that can significantly improve the efficiency and clarity of your code, so keep practicing and master its use to become an iteration expert!
Contributions 29
Questions 3
Want to see more contributions, questions and answers from the community?