How to use 'remove duplicates from array javascript using for loop' in JavaScript

Every line of 'remove duplicates from array javascript using for loop' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your JavaScript code is secure.

All examples are scanned by Snyk Code

By copying the Snyk Code Snippets you agree to
this disclaimer
25function removeDuplicates_for_loop(arr) {
26 let res = [];
27 const len = arr.length;
28 for (let i = 0; i < len; i++) {
29 if (res.indexOf(arr[i]) === -1) {
30 res.push(arr[i]);
31 }
32 }
33 return res;
34}
Important

Use secure code every time

Secure your code as it's written. Use Snyk Code to scan source code in minutes – no build needed – and fix issues immediately. Enable Snyk Code


Related snippets