1var numbers = [1, 2, 3, 4, 5];
2var length = numbers.length;
3for (var i = 0; i < length; i++) {
4 numbers[i] *= 2;
5}
6// numbers is now [2, 4, 6, 8, 10]
7
1var arr = [10,20,30,40,50]; //An Array is defined with 5 instances
2
3var len= arr.length; //Now arr.length returns 5.Basically, len=5.
4console.log(len); //gives 5
5console.log(arr.length); //also gives 5
1/*
2 Array Methods
3 - Length
4*/
5
6// Index Start From 0 [ 0, 1, 2, 3, 4 ]
7
8let myFriends = ["Ahmed", "Mohamed", "Sayed", "Alaa"];
9
10myFriends.length = 2;
11
12console.log(myFriends);
1
2const fruits = ["Banana", "Orange", "Apple", "Mango"];
3
4fruits.length // Returns 4
5