{"id":168,"date":"2011-10-28T00:37:37","date_gmt":"2011-10-28T04:37:37","guid":{"rendered":"http:\/\/www.joebillman.com\/blog\/?p=168"},"modified":"2011-10-28T00:37:37","modified_gmt":"2011-10-28T04:37:37","slug":"remove-duplicates-from-an-array-as3","status":"publish","type":"post","link":"https:\/\/www.joebillman.com\/blog\/?p=168","title":{"rendered":"Remove Duplicates from an Array AS3"},"content":{"rendered":"<p>I recently needed function that would remove duplicate values from an array. After looking around online and modifying what I found to fit my needs I came up with the following:<\/p>\n<pre style=\"background-color: #e5e5e5;\">var arr:Array = [\"a\", \"b\", \"c\", \"a\", \"d\", \"a\", \"a\"];\n\nremoveDuplicates(arr);\n\ntrace(arr);\n\nfunction removeDuplicates(target:Array):void\n{\n\tfor(var i:uint=target.length; i&gt;0; i--)\n\t{\n\t\tif(target.indexOf(target[i-1]) != i-1)\n\t\t{\n\t\t\ttarget.splice(i-1, 1);\n\t\t}\n\t}\n}<\/pre>\n<p>If you are searching for a way to do this, I hope this helps!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I recently needed function that would remove duplicate values from an array. After looking around online and modifying what I found to fit my needs I came up with the following: var arr:Array = [&#8220;a&#8221;, &#8220;b&#8221;, &#8220;c&#8221;, &#8220;a&#8221;, &#8220;d&#8221;, &#8220;a&#8221;, &#8220;a&#8221;]; removeDuplicates(arr); trace(arr); function removeDuplicates(target:Array):void { for(var i:uint=target.length; i&gt;0; i&#8211;) { if(target.indexOf(target[i-1]) != i-1) { &hellip; <a href=\"https:\/\/www.joebillman.com\/blog\/?p=168\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Remove Duplicates from an Array AS3&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2,26,27],"tags":[],"class_list":["post-168","post","type-post","status-publish","format-standard","hentry","category-actionscript","category-problem-solved","category-programming"],"_links":{"self":[{"href":"https:\/\/www.joebillman.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/168","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.joebillman.com\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.joebillman.com\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.joebillman.com\/blog\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.joebillman.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=168"}],"version-history":[{"count":0,"href":"https:\/\/www.joebillman.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/168\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.joebillman.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=168"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.joebillman.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=168"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.joebillman.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=168"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}