GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Merge pull request #2 from buckyroberts/master · karankeyash/JavaScript-Lessons@dfdc4b9

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • Data_Structures/Arrays/Basics
    • main.js
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎Data_Structures/Arrays/Basics/main.js‎

Copy file name to clipboardExpand all lines: Data_Structures/Arrays/Basics/main.js
+4-5Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,15 @@
1+
// to declare and initialize an array, you can pass all the items in as a list
12
var food = ['bacon', 'corn', 'ham', 'sausage'];
23

3-
// array values are retrieved by index, not name
4+
// array values are retrieved by index (starting at 0), not name
45
console.log(food[2]);
56
console.log(food.length);
67

7-
// loop over an array
8+
// you can iterate over an array to access each individual element
89
for(var i=0; i<food.length; i++){
910
console.log(i, food[i]);
1011
}
1112

12-
console.log('----------');
13-
1413
food.forEach(function (index, item) {
1514
console.log(item, index);
1615
});
@@ -44,6 +43,6 @@ console.log(food);
4443

4544
console.log('--------------------');
4645

47-
let numbers = [10, 32, 53, 99, 60];
46+
var numbers = [10, 32, 53, 99, 60];
4847
console.log(numbers.toString()); // comma separated list
4948
console.log(numbers.join('~')); // to use a different separator

0 commit comments

Comments
0 (0)
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.