Skip to main content

Command Palette

Search for a command to run...

StackOverflow love

Updated
1 min readView as Markdown

My first post on hashnode. Many of us depend on StackOverflow for solving day to day minor programming challenges. During these times, over the years, I have come across various gems of code. Let me start with my favorite piece of code I came across for the Javascript/Nodejs developers.

Filtering unique values in an array, attributed to this thread

myArray.filter((v, i, a) => a.indexOf(v) === i);

Yes, a lot of users have provided solutions including using the newer Set syntax. But I love the simplicity and power of the above one liner. Typically, while we know the filter method allows three arguments (value, index and array), we usually use only the value parameter and occasionally the index parameter. The brilliant use of the third array parameter to achieve uniqueness is what I love about this.

A

Looking forward to your future articles!

Will you cover mostly about Javascript or web development only?

R

Cover web development and Javascript. I am not a frequent publisher, but I plan to post articles atleast once or twice a month. Thanks for your interest