Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

remove duplicate item from array javascript

function remove_duplicates(arr) {
    var obj = {};
    var ret_arr = [];
    for (var i = 0; i < arr.length; i++) {
        obj[arr[i]] = true;
    }
    for (var key in obj) {
        ret_arr.push(key);
    }
    return ret_arr;
}
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #remove #duplicate #item #array #javascript
ADD COMMENT
Topic
Name
2+7 =