Remove continuous elements from an array

Software engineer | Web developer | Tech Enthusiast
Search for a command to run...

Software engineer | Web developer | Tech Enthusiast
No comments yet. Be the first to comment.
JavaScript developers have long relied on Promises to manage asynchronous code smoothlyβbut what if you need to catch errors and results from both synchronous and asynchronous functions consistently? Enter Promise.try(), a brand-new addition official...

As you become more experienced with JavaScript, you may encounter some advanced topics that can help you create even more powerful and efficient code. Here are a few Javascript Topics that you must know Callback Functions Callback functions are fun...

pow ** exponentiation operator raising the first operand to the power of the second more details explanation click here floor ~~ double bitwise not operator rounding a number towards zero more details explanation click here Wrapping up! Share thi...
charAt charAt method returns the character at the specified index in a string charCodeAt charCodeAt method returns Unicode of the character at the specified index in a string substr substr extracts the characters from a string, beginning at a speci...


in the above example, you have seen there is a repeating now I want to remove all continuous values only (not duplication) and keep 1st element of each repeating value
we can achieve that using the array filter method
Javascript filter accepts a callback function and that callback function accepts 3 arguments
element: it's return an current element
index(optional): it's return index current element
array(optional): it's return actual array on which filter is perform

so in the above code we first check if the element index is 0 or current element is not match with previous element then we return that element
Share this blog with your friends π©πΌβπ€βπ§πΌ and developers π¨βπ» you know and let them know about these
Your feedback and comments are very important to me. π