ARRAY:
An array is an object type,it is used for storing data collections.Multiple values store in a single variable.
FEATURES OF JAVASCRIPT ARRAYS are:
ELEMENT
An array a list of values are known as elements.ORDERED
Array elements are ordered
Based on their index.ZERO INDEXED
The first element is index 0,
Second element is 1.HETEROGENEOUS
Arrays can store elements of different datatypes.
(Strings,numbers,objects and other arrays)
WHY USE ARRAY:
let a = 10;
let b = 20;
let c = 30;
This is ok for 3 variables,how can manage 200,300 variables?.So use array.An array can store many values under a single name,can acces the values by referring to an index number.
Array syntax
let numbers = [10, 20, 30];
console.log(numbers[1]);
Output 20
BASIC ARRAY METHODSS
- Array length
- Array toString() – Convert to string
- Array at() –
- Array join()
- Array pop() – Remove last element
- Array push() – Add at end
- Array shift()
- Array unshift()
- Array isArray()
- Array delete()
- Array concat()
- Array copyWithin()
- Array flat()
- Array slice()
- Array splice()
- Array toSpliced()
1.Array length
Array length means length property returns the length(count,size)of an array.

Explanation:
🔹The array has 3 values,so length is 3.
🔹Even though index starts at 0, length counts from 1.
2.Array tostring()
The tostring methods returns the elements as of array commas as a seperated string.
Explanation
🔹The .toString() method converts the array into a string
🔹It automatically adds commas ( , ) between values
🔹output (1o,20,30)
3.Array at()
The at() methods returns an indexed element from an array.Including negative index.
Explanation
🔹at(0) → first element
🔹at(1) → second element
🔹at(2) → third element
🔹output
10
20
30
4.Array join()
This method is joins all array element into a string.its react like array tostring(),but add in specify the seperator.
Explanation
🔹 Converts array to string
🔹 Does not change original array
🔹 output( 10 20 30 )
Explanation
🔹 add in specify seperator
🔹 output(10*20*30)
5.Array pop()
Array pop method remove the last element from an array.
The pop() method returns the value that was "popped out":
Explanation
🔹Removes the last element 30
🔹Returns the removed value 30
🔹Updates the array → [10, 20]
🔹Output:
30
[ 10, 20 ]
6.Array push()
Array push() method is one or more new element add to an array at the last.
Explanation
🔹Adds element to the end
🔹Updates the original array.
push() returns the new arraylength.
push()return value

Explanation
🔹Adds elements to the end
🔹Changes the original array
🔹Returns new length
7.Array shift()
This method is remove fisrt element from an array and shifts all other element to a lower index.The shift() method returns the value that was "shifted out":
Explanation
🔹Removes the first element → 10
🔹Returns the removed value → 10
🔹Updates the array → [20, 30]
8.Array unshift()
The unshift() method is used to add one or more elements to the beginning (start) of an array.
Explanatioon
🔹Adds element at the start
🔹Moves existing elements to the right
The unshift() method returns the new array length:
Explaation
🔹 Adds elements to the beginning
🔹 Changes the original array
🔹 Returns new length
9.Array isArray()
Array.isArray() is used to check whether a value is an array or not.
Explanation
🔹true means its array
🔹false means its not array
10.array delete()
It is a delete keyword, but it is not recommended for arrays
Because it removes the value but keeps an empty slot (hole).
Explanation
🔹Index still exists
🔹Creates empty (undefined) space
11.Array concat()
The concat() method creates a new array by merging (concatenating) existing arrays:
Explanation:
🔹arr1 contains [10, 20]
🔹arr2 contains [30]
🔹concat() joins both arrays and returns a new array
🔹Original arrays are not changed












Top comments (0)