Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

how to find unique elements in array in javascript

let a = ["1", "1", "2", "3", "3", "1"];
let unique = a.filter((item, i, ar) => ar.indexOf(item) === i);
console.log(unique);
Comment

get unique numbers of an array in javascript using for loop

var array = [3,7,5,3,2,5,2,7];

for(var i=0;i<array.length;i++) {
    for(var j=i+1;j<array.length;j++) {
        if(array[i]===array[j]) {
            array.splice(j,1);
        }
    }
}
console.log(array); // output = [3,7,5,2]
 Run code snippet
Comment

javascript find unique values in array

// usage example:
var myArray = ['a', 1, 'a', 2, '1'];
var unique = myArray.filter((v, i, a) => a.indexOf(v) === i); 

// unique is ['a', 1, 2, '1']
Comment

PREVIOUS NEXT
Code Example
Javascript :: how to get session javascript ws3schools 
Javascript :: ngfor select angular 
Javascript :: bind to constructor 
Javascript :: get last element of getelementsbyclassname in js 
Javascript :: jetbrains font 
Javascript :: angular generate component 
Javascript :: javascript grab only even array index 
Javascript :: Uncaught ReferenceError: $localize is not defined angular 
Javascript :: document.getElementById visual basic 
Javascript :: how to check if you click something in javascript 
Javascript :: scroll to bottom of a div javascript 
Javascript :: input pattern for no whitespaces at the end or beginning 
Javascript :: how to filter an array of objects in javascript 
Javascript :: javascript scroll to bottom of div 
Javascript :: regular expression number from 1 to 100 
Javascript :: discord bot javascript remove user data in array 
Javascript :: using .indexOf() in jShell 
Javascript :: how to get orientation in js 
Javascript :: console.clear js 
Javascript :: js push param to url 
Javascript :: javascript get element by class name change style 
Javascript :: why my bootstrap classes is not working on onclick event in react 
Javascript :: create react app in current folder 
Javascript :: go to nextelementsibling js 
Javascript :: javascript autoplay audio 
Javascript :: loop through object element names javascript 
Javascript :: how to exclude a specefic tagname from a javascript query search 
Javascript :: value is array 
Javascript :: add formdata to axios request in js 
Javascript :: react native button 
ADD CONTENT
Topic
Content
Source link
Name
3+9 =