How to get unique values in an array

后端 未结 20 2374
情歌与酒
情歌与酒 2020-11-22 14:02

How can I get a list of unique values in an array? Do I always have to use a second array or is there something similar to java\'s hashmap in JavaScript?

I am going

20条回答
  •  猫巷女王i
    2020-11-22 14:46

    I was just thinking if we can use linear search to eliminate the duplicates:

    JavaScript:
    function getUniqueRadios() {
    
    var x=document.getElementById("QnA");
    var ansArray = new Array();
    var prev;
    
    
    for (var i=0;i

    }

    HTML:

    
    
    
    good avg Type1 Type2

提交回复
热议问题