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 — Working on courses · prafuldaga/JavaScript-Lessons@7d5b6a3

File tree

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

‎Data_Structures/Arrays/main.js‎

Copy file name to clipboardExpand all lines: Data_Structures/Arrays/main.js
+9-7Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
var food = ['bacon', 'corn', 'sausage'];
1+
var food = ['bacon', 'corn', 'ham', 'sausage'];
22

33
// array values are retrieved by index, not name
44
console.log(food[2]);
@@ -17,24 +17,26 @@ food.forEach(function (index, item) {
1717

1818
console.log('----------');
1919

20-
// add new items to an array
20+
// add new items to end of array
2121
food.push('tuna');
2222
console.log(food);
2323

24-
// remove item from the end of an array
24+
// remove item from the end of array
2525
var lastItem = food.pop();
2626
console.log(lastItem);
2727
console.log(food);
2828

29-
// remove item from the beginning of an array
30-
var firstItem = food.shift();
31-
console.log(firstItem);
32-
console.log(food);
29+
console.log('----------');
3330

3431
// add item to beginning of an array
3532
food.unshift('apples');
3633
console.log(food);
3734

35+
// remove item from the beginning of an array
36+
var firstItem = food.shift();
37+
console.log(firstItem);
38+
console.log(food);
39+
3840
// remove item by index position
3941
var pos = 1;
4042
food.splice(pos, 1);

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.