What are some of the array functions (methods) in javascript?

Some of the array functions (methods) in JavaScript are:

  1. push(): Adds one or more elements to the end of an array and returns the new length of the array.
let fruits = ['apple', 'banana'];
fruits.push('orange');
console.log(fruits); // Output: ['apple', 'banana', 'orange']

  1. pop(): Removes the last element from an array and returns that element.
let fruits = ['apple', 'banana', 'orange'];
let lastFruit = fruits.pop();
console.log(lastFruit); // Output: 'orange'
console.log(fruits); // Output: ['apple', 'banana']

  1. shift(): Removes the first element from an array and returns that element.
let fruits = ['apple', 'banana', 'orange'];
let firstFruit = fruits.shift();
console.log(firstFruit); // Output: 'apple'
console.log(fruits); // Output: ['banana', 'orange']

  1. unshift(): Adds one or more elements to the beginning of an array and returns the new length of the array.
let fruits = ['banana', 'orange'];
fruits.unshift('apple');
console.log(fruits); // Output: ['apple', 'banana', 'orange']

  1. concat(): Combines two or more arrays and returns a new array.
let fruits = ['apple', 'banana'];
let moreFruits = ['orange', 'mango'];
let allFruits = fruits.concat(moreFruits);
console.log(allFruits); // Output: ['apple', 'banana', 'orange', 'mango']

  1. slice(): Returns a shallow copy of a portion of an array into a new array.
let fruits = ['apple', 'banana', 'orange', 'mango'];
let citrusFruits = fruits.slice(2);
console.log(citrusFruits); // Output: ['orange', 'mango']

  1. splice(): Changes the contents of an array by removing, replacing, or adding elements.
let fruits = ['apple', 'banana', 'orange', 'mango'];
fruits.splice(1, 2, 'kiwi', 'grape');
console.log(fruits); // Output: ['apple', 'kiwi', 'grape', 'mango']

  1. forEach(): Executes a provided function once for each array element.
let fruits = ['apple', 'banana', 'orange'];
fruits.forEach(function(fruit) {
console.log(fruit);
});
// Output:
// 'apple'
// 'banana'
// 'orange'

These are just a few examples of the many array functions available in JavaScript.