concat
: Combines two or more arrays.join
: Joins all elements of an array into a string.slice
: Extracts a portion of an array.indexOf
and lastIndexOf
: Returns the index of the first or last occurrence of an element.filter
: Creates a new array with elements that satisfy a condition.map
: Creates a new array by applying a function to each element.reduce
: Applies a function to reduce the array to a single value.let arr=[1,2,3,4,5,6,7,8,9,10];
console.log(arr[0]);
console.log(arr[1]);
console.log(arr[20]);
let names=['Vignesh','Eswar','Fakrudddin'];
console.log(names[0]);
console.log(names[1]);
console.log(names[3]);
let names=['Vignesh','Eswar','Fakrudddin'];
console.log(names);
// For loop
for(let i=0;i<names.length;i++){
console.log(names[i]);
}
// For of loop
for(let name of names){
console.log(name);
}
// For each loop
names.forEach(function(name){
console.log(name);
});
array.push(item1,item2,item3,...)
at the end of array
array.unshift(item1,item2,item3,...)
at the front of array
array.splice(startIndex,deleteCount,itemsToInsert)
at startIndex
let names=['Vignesh','Eswar','Fakrudddin'];
console.log(names);
// Insert at beginning of array - unshift()
names.unshift('Pavan','Sumanth');
console.log(names);
// Insert at end of array - push()
names.push('Dhanush','Susruth');
console.log(names);
// Insert at specific index - splice()
names.splice(2,0,'Thrinath');
console.log(names);