JavaScript Arrays: Properties & Methods Guide

Arrays in JavaScript are a global object used for creating and manipulating arrays.

Characteristics:

  1. Array.length: Returns the length of the array.

Method:

  1. Array.from(): Converts array-like objects or iterable objects into real arrays.
  2. Array.isArray() checks whether the given value is an array.
  3. Array.of(): Creates a new array instance with a variable number of parameters.
  4. Array.prototype.concat(): Combines two or more arrays together and returns a new array.
  5. The copyWithin() method of Array object copies elements from a specified position within the array to another specified position within the same array.
  6. Array.prototype.entries(): Returns a new Array Iterator object that contains key/value pairs for each index in the array.
  7. Array.prototype.every() checks if all elements in an array pass a certain test function.
  8. Array.prototype.fill(): Fills all elements in an array from a starting index to an ending index with a fixed value.
  9. Array.prototype.filter(): Create a new array containing all elements that pass the test specified by a given function.
  10. Array.prototype.find(): Returns the value of the first element in the array that satisfies the provided testing function.
  11. Array.prototype.findIndex(): Returns the index of the first element in the array that satisfies the provided testing function.
  12. Array.prototype.flat(): Recursively concatenates all elements of nested arrays into a new array.
  13. Array.prototype.flatMap(): First map each element using a mapping function, then compress the results into a new array.
  14. The forEach() method of the Array object executes a specified operation on each element of the array.
  15. Array.prototype.includes() checks if an array includes a certain value.
  16. Array.prototype.indexOf(): Returns the index of the first matching element in the array, or -1 if it does not exist.
  17. Array.prototype.join(): concatenate all elements in the array into a single string.
  18. Array.prototype.keys(): Return a new Array Iterator object that includes the keys of each index in the array.
  19. The Array.prototype.lastIndexOf() method returns the index of the first matching element starting from the end of the array, or -1 if the element is not found.
  20. The Array.prototype.map() method creates a new array with the results of calling a provided function on every element in the array.
  21. Array.prototype.pop() removes and returns the last element of an array.
  22. The method Array.prototype.push() is used to add one or more elements to the end of an array and returns the new length of the array.
  23. Array.prototype.reduce(): Apply a provided function to each element in the array and accumulate the results into a single value.
  24. Array.prototype.reduceRight(): Applies a function to each element of the array (from right to left) and combines the results into a single value.
  25. Reverse the order of elements in an array using Array.prototype.reverse().
  26. Array.prototype.shift(): Removes and returns the first element of the array.
  27. The Array.prototype.slice() method returns a new array containing some elements of the original array.
  28. Array.prototype.some(): Test whether at least one element in an array passes the test implemented by the specified function.
  29. Sort the elements of an array using Array.prototype.sort().
  30. Array.prototype.splice(): Modify the contents of an array by deleting or replacing existing elements or adding new elements.
  31. Array.prototype.toLocaleString(): Returns a string representing the elements of the array.
  32. Array.prototype.toString(): Returns a string representing the elements in the array.
  33. Array.prototype.unshift(): Add one or more elements to the beginning of an array and return the new length.
  34. Array.prototype.values(): Returns a new Array Iterator object that contains the values of each index in the array.

These are some commonly used properties and methods of Array objects, you can choose the appropriate method to manipulate arrays as needed.

bannerAds