Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions src/data-structures/arrays/array.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,18 @@ array.splice(4, 2); // array: [0, 2, 5, 1, 7, 4, empty, 3]
array.splice(1, 0, 111); // at the postion 1, delete 0 elements and insert 111
//=> array: [2, 111, 5, 1, 9, 6, 7]

//Iterating towards the given elements
// Using a for loop
for (let i = 0; i < array.length; i++) {
console.log(array[i]);
}

// Using forEach
fruits.forEach(function (fruit) {
console.log(fruit);
});


// Deleting from the beginning of the array.
array.shift(); //=> [5, 1, 9, 6, 7]

Expand Down