close

How to print elements from array with javascript

Hello Guys, How are you all? Hope You all Are Fine. Today we are going to learn How to print elements from array with javascript in javascript. So Here I am Explain to you all the possible methods here.

Without wasting your time, Let’s start This Article.

How to print elements from array with javascript ?

  1. How to print elements from array with javascript ?

    print elements from array with javascript Try to use for loop :
    for (var i=0; i<array.length; i++) console.log(i + ". " + array[i]);

  2. print elements from array with javascript

    print elements from array with javascript Try to use for loop :
    for (var i=0; i<array.length; i++) console.log(i + ". " + array[i]);

Method 1

Use forEach for this like below(ES6)

var a = ["a", "b", "c"];
a.forEach((element) => {
        console.log(element)
    }
);

Method 2

Try to use for loop :

for (var i=0; i<array.length; i++)
    console.log(i + ". " + array[i]);

Summery

It’s all About this article. Hope all method helped you a lot. Comment below Your thoughts and your queries. Also, Comment below which method worked for you? Thank You.

Leave a Comment