JavaScript Array Question 8

Introduction

What is the output of the following code?


// let's create an array for testing
let myNumArray = [1,2,3,4,5,6,7];

// iterate over a loop using a simple for loop. 
for (i = 0; i < myNumArray.length; i++) {
     console.log( myNumArray[i] + "," );
}
// 1,2,3,4,5,6,7, 

console.log();//from  www.  j a  v a  2  s . c o m

// here we cache the value of myNumArray for speed
for (let i = 0, mylen = myNumArray.length; i < mylen; i++) {
     console.log( myNumArray[i] + "," );
}


1,
2,
3,
4,
5,
6,
7,

1,
2,
3,
4,
5,
6,
7,



PreviousNext

Related