ItSolutionStuff.com

Node JS Foreach Loop Array Example

By Hardik Savani • November 5, 2023
Node JS

Hello all! In this article, we will talk about node js foreach loop array. In this article, we will implement a foreach loop node.js array. Here you will learn for loop in node js array. This post will give you simple example of for loop in node js json array.

i will give you two simple example with node foreach loop. let's see both example one by one.

Example 1:

const myArray = ['PHP', 'Laravel', 'Angular', 'React', 'Node'];

myArray.forEach(element => {

console.log(element);

});

Output:

PHP

Laravel

Angular

React

Node

Example 2:

const myArray = [1, 2, 3, 4, 5, 7];

myArray.forEach((element, index) => {

console.log('Key:' + index + ' Value:' + element);

});

Output:

Key:0 Value:1

Key:1 Value:2

Key:2 Value:3

Key:3 Value:4

Key:4 Value:5

Key:5 Value:7

i hope it can help you...

Tags: Node JS
Hardik Savani

Hardik Savani

I'm a full-stack developer, entrepreneur, and founder of ItSolutionStuff.com. Passionate about PHP, Laravel, JavaScript, and helping developers grow.

📺 Subscribe on YouTube

We Are Recommending You

Axios HTTP requests in Node JS Example

Read Now →

Node JS Http Request with Headers Example

Read Now →

Node JS Make HTTP Put Request Example

Read Now →

Node JS Make HTTP Delete Request Example

Read Now →

Node JS Make Http Get Request with Parameters Example

Read Now →

How to make an HTTP POST request in Node JS?

Read Now →

How to run node js server on https using self-signed certificate?

Read Now →

Node JS Mysql Connection Example

Read Now →

Node JS Convert Image File to Base64 String Example

Read Now →

Node js Express Multiple Image Upload using Multer Example

Read Now →

Node js Express Image Upload using Multer Example

Read Now →

How to Upgrade Node.js Version in Ubuntu?

Read Now →