Cagri Kizilkan ๐Ÿ‡บ๐Ÿ‡ฆ Profile picture
Freelance Front-End Web Developer | Tweets about HTML, CSS and JavaScript | Check out my Free SEO Tools website : https://t.co/dOIiGzPjvW

Jul 30, 2022, 27 tweets

๐Ÿ“Œ 24 Array Methods in JavaScript:

Mega Thread ๐Ÿงต ๐Ÿ‘‡

#LearnToCode #CodeNewbie

1) concat():

๐Ÿ”น Concatenates (joins) two or more arrays.

๐Ÿ”น Returns a new array, containing the joined arrays.

๐Ÿ”น Does not change the existing arrays.

2) copyWithin():

๐Ÿ”น Copies array elements to another position in the array.

๐Ÿ”น Overwrites the existing values.

๐Ÿ”น Does not add items to the array.

3) every():

๐Ÿ”น Executes a function for each array element.

๐Ÿ”น Returns `true` if the function returns true for all elements, otherwise returns `false`.

๐Ÿ”น Does not execute the function for empty elements.

๐Ÿ”น Does not change the original array.

4) fill():

๐Ÿ”น Fills specified elements in an array with a value.

๐Ÿ”น Overwrites the original array.

๐Ÿ”น Start and end position can be specified. If not, all elements will be filled.

5) filter():

๐Ÿ”น Creates a new array filled with elements that pass a test provided by a function.

๐Ÿ”น Does not execute the function for empty elements.

๐Ÿ”น Does not change the original array.

6) find():

๐Ÿ”น Returns the value of the first element that passes a test. Returns `undefined` if no elements are found.

๐Ÿ”น Executes a function for each array element.

๐Ÿ”น Does not execute the function for empty elements.

๐Ÿ”น Does not change the original array.

7) findIndex():

๐Ÿ”น Returns the the index (position) of the first element that passes a test. Returns -1 if no match is found.

๐Ÿ”น Executes a function for each array element.

๐Ÿ”น Does not execute the function for empty elements.

๐Ÿ”น Does not change the original array.

8) from():

๐Ÿ”น Returns an array from any object with a length property.

9) includes():

๐Ÿ”น Returns `true` if an array contains a specified value, otherwise returns `false`.

๐Ÿ”น This method is case sensitive.

10) indexOf():

๐Ÿ”น Returns the first index (position) of a specified value. Returns -1 if the value is not found.

๐Ÿ”น Starts at a specified index and searches from left to right.

๐Ÿ”น Negative start values counts from the last element (but still searches from left to right).

11) isArray():

๐Ÿ”น Returns `true` if an object is an array, otherwise `false`.

12) join():

๐Ÿ”น Returns an array as a string.

๐Ÿ”น Does not change the original array.

13) lastIndexOf():

๐Ÿ”น Returns the last index (position) of a specified value. Returns -1 if the value is not found.

๐Ÿ”น Starts at a specified index and searches from right to left.

๐Ÿ”น Negative start values counts from the last element (but still searches from right to left).

14) map():

๐Ÿ”น Creates a new array from calling a function for every array element.

๐Ÿ”น Calls a function once for each element in an array.

๐Ÿ”น Does not execute the function for empty elements.

๐Ÿ”น Does not change the original array.

15) pop():

๐Ÿ”น Removes (pops) the last element of an array.

๐Ÿ”น Changes the original array.

๐Ÿ”น Returns the removed element.

16) push():

๐Ÿ”น Adds new items to the end of an array.

๐Ÿ”น Changes the length of the array.

๐Ÿ”น Returns the new length.

17) reduce():

๐Ÿ”น Executes a reducer function for each array element.

๐Ÿ”น Returns a single value: the function's accumulated result.

๐Ÿ”น Does not execute the function for empty array elements.

๐Ÿ”น Does not change the original array.

18) reverse():

๐Ÿ”น Reverses the order of the elements in an array.

๐Ÿ”น Overwrites the original array.

19) shift():

๐Ÿ”น Removes the first item of an array.

๐Ÿ”น Changes the original array.

๐Ÿ”น Returns the shifted element.

20) slice():

๐Ÿ”น Returns selected elements in an array, as a new array.

๐Ÿ”น Selects from a given start, up to a (not inclusive) given end.

๐Ÿ”น Does not change the original array.

21) some():

๐Ÿ”นChecks if any array elements pass a test.

๐Ÿ”น Executes the callback function once for each array element.

๐Ÿ”น Returns true (and stops) if the function returns true for one of the array elements. Otherwise returns false.

22) sort():

๐Ÿ”น Sorts the elements of an array.

๐Ÿ”น Overwrites the original array.

๐Ÿ”น Sorts the elements as strings in alphabetical and ascending order.

23) splice():

๐Ÿ”น Adds and/or removes array elements.

๐Ÿ”น Overwrites the original array.

24) unshift():

๐Ÿ”น Adds new elements to the beginning of an array.

๐Ÿ”น Overwrites the original array.

That's a wrap!

If you found it useful, please consider:

๐Ÿ”นFollow me @cgrkzlkn for more content on HTML, CSS and JavaScript ๐Ÿง‘โ€๐Ÿ’ป
๐Ÿ”นLike โค๏ธ
๐Ÿ”นRetweet the first tweet โšก๏ธ

You can read unrolled version of this thread:

threadreaderapp.com/thread/1553468โ€ฆ

Share this Scrolly Tale with your friends.

A Scrolly Tale is a new way to read Twitter threads with a more visually immersive experience.
Discover more beautiful Scrolly Tales like this.

Keep scrolling