Get the App
SLTechnology News&Howtos  ›  Development  › 

How to use filter to remove weight in JavaScript

Shulou Source: shulou.com Published: 2022-06-01 02:31:52 09月21日 Update

Editor to share with you how JavaScript uses filter to remove weight, I believe most people do not know much about it, so share this article for your reference, I hope you can learn a lot after reading this article, let's go to know it!

Using filter

Function unique (arr) {return arr.filter (function (item, index, arr) {/ / current element, first index in the original array = = current index value, otherwise return current element return arr.indexOf (item, 0) = index;}) } var arr = [1 unique (arr)) / / [1, true, true,15, false, undefined, null, NaN ", 0," a ", {… }, {... }] these are all the contents of the article "how to use filter to remove JavaScript". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

Tags: Articles elements content index original not much most arrays more knowledge industry information information channels channels references learning help Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno NVidia Huawei macOS OPPO Reno Apple