[JavaScript]filter / CallbackFunction /
👋 Hi there! I'm Suzie, a developer who began my coding journey in 2023. I’m passionate about building fast and dynamic web experiences using Next.js, JavaScript, and Tailwind CSS.
🌱 As I grow in tech, I enjoy documenting my learning journey and sharing insights to help others navigate their path.
✨ Fun fact: When I’m not coding, you can find me practicing Capoeria 🤸.
Let’s connect, learn, and create together!
How to use filter in JavaScript
arrayName.filter((element, index) => element !== arr[index+1];
const arr =[1,1,2,2,3,3];
const answer = arr.filter((x,y) => x !== arr[y+1]);
console.log(answer);
//expacted result : [1,2,3]
x -> value (ex. 1) y -> index (ex. [0])
filter will scan all the elements in the array and filter which is matched with the condition.

![[TypeScript] Understanding Generic Functions](https://cdn.hashnode.com/res/hashnode/image/stock/unsplash/NH0pmKaZeuk/upload/47eb76a03d44ea841c42f406a93de157.jpeg)
