Skip to content

Yakobus-Mardi/JavaScript-Array-Methods

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

3 Commits
Β 
Β 

Repository files navigation

JavaScript-Array-Methods

Idk who need this, but I think this Repo can help πŸ™‚

  • .pop()removes LAST element of array and returns that removed element. Changes the original array.
  • .push()adds one or more element to the BACK of array. Changes the original array. Returns the length of the changed array.
  • .shift()removes the FIRST element of an array, and returns the removed element. Changes the original array and its length.
  • .unshift()adds one or more elements to the START of an array, and returns the new length of the array.
  • .slice()selects part of array & returns a COPY of all elements selected from start index to end index. The original array does NOT change.
  • .splice()removes, replaces, or adds new element to the array. Returns array of the deleted elements. Changes the original array.
  • .join()returns a NEW STRING of array elements either separated by commas or a specified separator.
  • .toString()converts an array into a string.
  • .forEach()loops through the elements of an array. For every array element, it executes a callback function.
  • .filter()returns a NEW array that 'filters' out elements from an array. If element meets condition from callback, it's added to new array.
  • .includes()checks if the array includes the item passed to the method. It returns either "true" or "false".
  • .map()creates a NEW array with the return value of the callback function called on each element.
  • Array.from()creates a NEW array from an array-like/iterable object.
  • .concat()merges two or more arrays into a NEW array.
  • .reverse()reverses an array; the first element becomes last, and the last becomes first. It changes the original array.
  • .sort()sorts the elements of an array in ascending order of UTF-16. It cahnges the original array, and returns the sorted array.
  • .every()tests if every element in an array passes the test implemented by the callback function. It returns a boolean value.
  • .some()returns 'true' if ANY (some) element in the array passes the test implemented by the callback function.
  • .reduce()reduces the array into a single element. It passes the return value of the previous element in the callback function.
  • .findIndex()returns the index of the first element in the array that satisfies the callback function.

About

Idk who need this, but I think this Repo can help πŸ™‚

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published