DEV Community

Areeba Farooq
Areeba Farooq

Posted on

1

𝟰 𝗺𝗮𝗶𝗻 𝗝𝗮𝘃𝗮𝗦𝗰𝗿𝗶𝗽𝘁 𝗺𝗲𝘁𝗵𝗼𝗱𝘀 𝘁𝗼 𝗿𝗲𝗺𝗼𝘃𝗲 𝗲𝗹𝗲𝗺𝗲𝗻𝘁𝘀 𝗶𝗻 𝘁𝗵𝗲 𝗮𝗿𝗿𝗮𝘆,🚀

🚀 𝟰 𝗺𝗮𝗶𝗻 𝗝𝗮𝘃𝗮𝗦𝗰𝗿𝗶𝗽𝘁 𝗺𝗲𝘁𝗵𝗼𝗱𝘀 𝘁𝗼 𝗿𝗲𝗺𝗼𝘃𝗲 𝗲𝗹𝗲𝗺𝗲𝗻𝘁𝘀 𝗶𝗻 𝘁𝗵𝗲 𝗮𝗿𝗿𝗮𝘆:

  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

AWS Security LIVE!

Join us for AWS Security LIVE!

Discover the future of cloud security. Tune in live for trends, tips, and solutions from AWS and AWS Partners.

Learn More

Top comments (0)

SurveyJS custom survey software

Build Your Own Forms without Manual Coding

SurveyJS UI libraries let you build a JSON-based form management system that integrates with any backend, giving you full control over your data with no user limits. Includes support for custom question types, skip logic, an integrated CSS editor, PDF export, real-time analytics, and more.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay