DEV Community

Areeba Farooq
Areeba Farooq

Posted on

๐Ÿฐ ๐—บ๐—ฎ๐—ถ๐—ป ๐—๐—ฎ๐˜ƒ๐—ฎ๐—ฆ๐—ฐ๐—ฟ๐—ถ๐—ฝ๐˜ ๐—บ๐—ฒ๐˜๐—ต๐—ผ๐—ฑ๐˜€ ๐˜๐—ผ ๐—ฟ๐—ฒ๐—บ๐—ผ๐˜ƒ๐—ฒ ๐—ฒ๐—น๐—ฒ๐—บ๐—ฒ๐—ป๐˜๐˜€ ๐—ถ๐—ป ๐˜๐—ต๐—ฒ ๐—ฎ๐—ฟ๐—ฟ๐—ฎ๐˜†,๐Ÿš€

๐Ÿš€ ๐Ÿฐ ๐—บ๐—ฎ๐—ถ๐—ป ๐—๐—ฎ๐˜ƒ๐—ฎ๐—ฆ๐—ฐ๐—ฟ๐—ถ๐—ฝ๐˜ ๐—บ๐—ฒ๐˜๐—ต๐—ผ๐—ฑ๐˜€ ๐˜๐—ผ ๐—ฟ๐—ฒ๐—บ๐—ผ๐˜ƒ๐—ฒ ๐—ฒ๐—น๐—ฒ๐—บ๐—ฒ๐—ป๐˜๐˜€ ๐—ถ๐—ป ๐˜๐—ต๐—ฒ ๐—ฎ๐—ฟ๐—ฟ๐—ฎ๐˜†:

  1. ๐—ฝ๐—ผ๐—ฝ -Removes from the end of an Array.

  2. ๐˜€๐—ต๐—ถ๐—ณ๐˜ - Removes from the beginning of Array.

  3. ๐˜€๐—ฝ๐—น๐—ถ๐—ฐ๐—ฒ -removes from a specific array Index.

  4. ๐—ณ๐—ถ๐—น๐˜๐—ฒ๐—ฟ -allows you to programmatically remove elements from array.


but here I'm going to look at two most used methods
splice and filter.

- Splice():

when you use a splice, you need to find the index to the array element you want to remove using indexOf() and then remove that index with splice.

The splice () method changes the contents of an array by removing the existing element

array.splice((array).index0f(element_To_be _removed),1)


- filter ():

here is the code for the filter

myArray.filter(obj => obj !== myobject)

anyone who wants to explain more how filters work, you can share in the comment section

Top comments (0)