JavaScript wrangler.
Check out my books!
Modern CSS:
https://www.amazon.com/dp/148426293X
Using Gatsby and Netlify CMS:
https://www.amazon.com/dp/1484262964
JavaScript wrangler.
Check out my books!
Modern CSS:
https://www.amazon.com/dp/148426293X
Using Gatsby and Netlify CMS:
https://www.amazon.com/dp/1484262964
Sometimes hacks make it into production code and become technical debt. This is not a hack that should ever be in a real application.
There are a lot of beginners on DEV and when they see posts like this it teaches them really bad practices. Particularly here since you have tagged it with #beginners.
Besides, your "solution" is for comparing arrays of numbers only. Comparing two arrays containing just numbers is easy with a simple loop since there aren't nested properties, etc.
With both of the above approaches, it bails out as soon as it finds two array elements that are not unique. Stringifying and comparing strings (yuck) requires processing each array in full.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Agreed
So you agree that your own post is a bad idea? 🤔
yes there is always drawbacks of easy hacks.
But if you're confident about your input you might as well ues this
Sometimes hacks make it into production code and become technical debt. This is not a hack that should ever be in a real application.
There are a lot of beginners on DEV and when they see posts like this it teaches them really bad practices. Particularly here since you have tagged it with #beginners.
Besides, your "solution" is for comparing arrays of numbers only. Comparing two arrays containing just numbers is easy with a simple loop since there aren't nested properties, etc.
You could also use
Array.prototype.every
for a one-liner:With both of the above approaches, it bails out as soon as it finds two array elements that are not unique. Stringifying and comparing strings (yuck) requires processing each array in full.