Skip to content

WebDevHubs

  • Home
  • Web Technologies
  • HTML
  • CSS
  • JavaScript
  • Java
  • Selenium
  • PHP
  • Python
  • Programs
  • Toggle search form

JavaScript Array Methods

Posted on December 4, 2024July 23, 2025 By Admin No Comments on JavaScript Array Methods

JavaScript Array Methods provide powerful built-in functions to perform operations on array. These methods simplifies the operations like – adding, removing, searching, sorting, filtering, and other operations.

Here is an example that demonstrates the basic array operations.

// Initial array of numbers
let arr = [10, 20, 30, 40, 50];

// 1. Adding numbers to the array
arr.push(60); // Add 60 at the end
arr.unshift(5); // Add 5 at the beginning
console.log("After Adding Elements:", arr);
// Output: After Adding Elements: [ 5, 10, 20, 30, 40, 50, 60 ]


// 2. Filtering numbers greater than 50
let nums = arr.filter(num => num <= 30);
console.log("Numbers Less Than or Equal to 50:", nums);
// Output: Numbers Less Than or Equal to 50: [ 5, 10, 20, 30 ]


// 3. Doubling the values
let doubledNums = arr.map(num => num * 2);
console.log("Doubled Values:", doubledNums);
// Output: Doubled Values: [ 10,  20,  40, 60, 80, 100, 120 ]


// 4. Sorting in Descending Order
let sortedNums = arr.sort((a, b) => b - a);
console.log("Sorted in Descending Order:", sortedNums);
// Output: Sorted in Descending Order: [ 60, 50, 40, 30, 20, 10,  5 ]

Below are the list of all JavaScript array methods with their brief description.

Method/PropertyDescription
JavaScript Array() constructorCreates a new array instance (Array object).
JavaScript Array.from() MethodCreates an array from an array-like or iterable object.
JavaScript Array.fromAsync() MethodCreates an array from an async iterable or promises.
JavaScript Array.isArray() MethodChecks if a value is an array.
JavaScript Array.of() MethodCreates an array from arguments provided.
JavaScript Array at() MethodReturns the element at a specific index, supporting negative indices.
JavaScript Array concat() MethodMerges two or more arrays into a new array.
JavaScript Array copyWithin() MethodCopies part of an array to another location within the same array.
JavaScript Array entries() MethodReturns an iterator with key-value pairs for array indices and values.
JavaScript Array every() MethodTests if all elements pass a given condition.
JavaScript Array fill() MethodFills elements with a static value from a start to an end index.
JavaScript Array filter() MethodCreates a new array with elements that pass a condition.
JavaScript Array find() MethodReturns the first element that satisfies a condition.
JavaScript Array findIndex() MethodReturns the index of the first element that satisfies a condition.
JavaScript Array findLast() MethodReturns the last element that satisfies a condition.
JavaScript Array findLastIndex() MethodReturns the index of the last element that satisfies a condition.
JavaScript Array flat() MethodFlattens nested arrays into a single-level array.
JavaScript Array flatMap() MethodMaps and flattens the array in one operation.
JavaScript Array forEach() MethodExecutes a function for each array element.
JavaScript Array includes() MethodChecks if an array contains a specified value.
JavaScript Array indexOf() MethodReturns the index of the first occurrence of a value.
JavaScript Array join() MethodJoins all elements into a string using a specified separator.
JavaScript Array keys() MethodReturns an iterator for the array indices.
JavaScript Array lastIndexOf() MethodReturns the index of the last occurrence of a value.
JavaScript Array map() MethodCreates a new array by applying a function to each element.
JavaScript Array pop() MethodRemoves and returns the last element of an array.
JavaScript Array push() MethodAdds one or more elements to the end of an array.
JavaScript Array reduce() MethodReduces the array to a single value using a function.
JavaScript Array reduceRight() MethodReduces the array to a single value, iterating from right to left.
JavaScript Array reverse() MethodReverses the order of array elements.
JavaScript Array shift() MethodRemoves and returns the first element of an array.
JavaScript Array slice() MethodReturns a shallow copy of part of an array.
JavaScript Array some() MethodTests if at least one element passes a given condition.
JavaScript Array sort() MethodSorts the array in place based on a comparison function.
JavaScript Array splice() MethodAdds or removes elements from an array at a specified index.
JavaScript Array toLocaleString() MethodConverts elements to strings using locale settings.
JavaScript Array toReversed() MethodReturns a new array with reversed elements without modifying the original array.
JavaScript Array toSorted() MethodReturns a new array with sorted elements without modifying the original array.
JavaScript Array toSpliced() MethodReturns a new array after splicing, without modifying the original array.
JavaScript Array toString() MethodConverts the array to a string of elements separated by commas.
JavaScript Array unshift() MethodAdds one or more elements to the beginning of an array.
JavaScript Array values() MethodReturns an iterator for the array values.
JavaScript Array with() MethodReturns a new array with an updated value at a specified index.
JavaScript Array length PropertyReturns the number of elements in the array.

JavaScript, Web Technologies Tags:JavaScript-Array, JavaScript-Array-Method

Post navigation

Previous Post: Array in JavaScript
Next Post: JavaScript Array indexOf() Method

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

  • JavaScript Array Methods
  • JavaScript Array.from() Method
  • JavaScript Array isArray() Method
  • JavaScript Array at() Method
  • JavaScript Array every() Method
  • JavaScript Array filter() Method
  • JavaScript Array find() Method
  • JavaScript Array forEach() Method
  • JavaScript Array includes() Method
  • JavaScript Array indexOf() Method
  • JavaScript Array join() Method
  • JavaScript Array keys() Method
  • JavaScript Array lastIndexOf() Method
  • JavaScript Array map() Method
  • JavaScript Array pop() Method
  • JavaScript Array push() Method
  • JavaScript Array reduce() Method
  • JavaScript Array reduceRight() Method
  • JavaScript Array reverse() Method
  • JavaScript Array shift() Method
  • JavaScript Array slice() Method
  • JavaScript Array some() Method
  • JavaScript Array sort() Method
  • JavaScript Array splice() Method
  • JavaScript Array toLocaleString() Method
  • JavaScript Array toReversed() Method
  • JavaScript Array toSorted() Method
  • JavaScript Array toSpliced() Method
  • JavaScript Array toString() Method
  • JavaScript Array unshift() Method
  • JavaScript Array values() Method
  • JavaScript Array with() Method

Recent Posts

  • Java ArrayList trimToSize() Method
  • Java ArrayList toArray() Method
  • Java ArrayList subList() Method
  • Java ArrayList spliterator() Method
  • Java ArrayList sort() Method

Recent Comments

No comments to show.

Important Pages

  • About Us
  • Contact Us
  • Terms of Use
  • Privacy Policy

Web Development

  • HTML
  • CSS
  • JavaScript
  • PHP

Programming Languages

  • Java
  • Python
  • PHP
  • Programs

Others

  • Selenium
  • Lodash
  • Java ArrayList
  • JavaScript Array Methods

Copyright © 2025 WebDevHubs.

Powered by PressBook Green WordPress theme