JavaScript for Beginners #51 The forEach() Array Method

preview_player
Показать описание
Here, we will learn how to use the forEach() method for arrays in JavaScript. The forEach() method will execute a provided function, known as a callback function one for each array element.

Syntax from MDN page linked below:
// execute something
}[, thisArg]);

Last Example in the lesson:

class Friend {
constructor(firstName, lastName, age, job) {
}
fullName() {
}
}
const friend1 = new Friend("John", "Peters", 35, "teacher 👩🏫");
const friend2 = new Friend("James", "Smith", 40, "programmer 💻");
const friend3 = new Friend("Jennifer", "Dalton", 28, "doctor 👩⚕️");
const friend4 = new Friend("Molly", "Brown", 22, "accountant 🔢");
const friend5 = new Friend("Becky", "Edwards", 31, "florist 🌷");

const friends = [friend1, friend2, friend3, friend4, friend5];

0:00 Introduction what is the forEach() method
0:18 Setting up an array of bank transactions
0:52 Looping through the array with a for loop
3:50 Using the forEach() method
7:45 Settin up an array with the numbers 1 through 7
10:24 Setting up an array of objects

JavaScript Playlist:

MDN forEach() Method:

MDN Classes:

NodeJS:

VS Code:
Рекомендации по теме
Комментарии
Автор

Good idea with putting the Friend objects in the description. P.S. I called my variable a 'friendo' #NoCountryForOldMen

laponiec