¾È±Ô °øºÎ¹æ

Javascript & JQuery & CSS > jQuery ¹è¿­ Áߺ¹ Á¦°Å

µî·ÏÀÏ : 2017-07-04 19:36 Á¶È¸¼ö : 53,784


        var test = ["2", "45", "7", "7", "21", "21", "45", "54", "54", "8", "5", "5", "44", "44", "5", "44"];
        var arrDistinct = new Array();
        $(document).ready(function() {
            $(test).each(function(index, item) {
                if ($.inArray(item, arrDistinct) == -1)
                    arrDistinct.push(item);
                $("#container").append($("<li>").html(item));
            });

            $(arrDistinct).each(function(index, item) {
                $("#distinct").append($("<li>").html(item));
            });
        });
   

		======================================================================


        function removeDuplicates(inputArray) {
            var i;
            var len = inputArray.length;
            var outputArray = [];
            var temp = {};

            for (i = 0; i < len; i++) {
                temp[inputArray[i]] = 0;
            }
            for (i in temp) {
                outputArray.push(i);
            }
            return outputArray;
        }

        var inputArray = [1, 1, 4, 5, 6, 7, 7, 8, 8, 9, 8, 9, 8, 0, 6, 8, 4, 3, 5, 6];

        //Output- 1,4,5,6,7,8,9,0,3
        var ouputArray = removeDuplicates(inputArray);
        
        alert(ouputArray);
 
¡Ø Ȥ½Ã µµ¿òÀÌ µÇ¼Ì´Ù¸é ´ñ±Û¿¡ ÇѸ¶µð ³²°ÜÁÖ¼¼¿ä!
ÀÛ¼ºÀÚ   ºñ¹Ð¹øÈ£
ÀÚµ¿±Û ¹æÁö     (ÀÚµ¿±Û ¹æÁö ±â´ÉÀÔ´Ï´Ù.)
³»¿ë   ´ñ±Û´Þ±â 
À̸ÞÀÏ ¹®ÀÇ : cak0280@nate.com  
Copyright 2000 By ENTERSOFT.KR All Rights Reserved.