| Viewed 139 times

how to get all array item in javascript


how to get all array item in javascript

1 Answer
Mohammad Qandeel
Answered
20

you need to use foreach to loop throw array items 

example 

<script>
var a =[1,2,3];
a.forEach((v,i,ar)=>{
	console.log(`${i} : ${v}`);
});
</script>

output 

0 : 1

1 : 2

2 : 3



Related Questions