|
|
<div id="cnblogs_post_body">第一种是比较常规的方法
思路:
1.构建一个新的数组存放结果
2.for循环中每次从原数组中取出一个元素,用indexOf查找新数组中是否有该元素
3.若没有,则存到结果数组中
<div id="highlighter_465816" class="syntaxhighlighter" style="margin: 1em 0px !important; padding: 0px !important; border: 1px solid #e0e0e0 !important; outline: 0px !important; background-image: none !important; background-color: #ffffff !important; text-align: left; float: none !important; vertical-align: baseline !important; position: relative !important; left: auto !important; top: auto !important; right: auto !important; bottom: auto !important; height: auto !important; width: 633.5833129882813px; line-height: 1.1em !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; font-weight: normal; font-style: normal; font-size: 14px; direction: ltr !important; color: #555555; font-variant: normal; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; background-position: initial initial !important; background-repeat: initial initial !important;"><div class="lines" style="margin: 0px !important; padding: 0px !important; border: 0px !important; outline: 0px !important; background-image: none !important; text-align: left !important; float: none !important; vertical-align: baseline !important; position: static !important; left: auto !important; top: auto !important; right: auto !important; bottom: auto !important; height: auto !important; width: auto !important; line-height: 1.1em !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; font-weight: normal !important; font-style: normal !important; font-size: 1em !important; direction: ltr !important; background-position: initial initial !important; background-repeat: initial initial !important;"><div class="line alt1" style="margin: 0px !important; padding: 0px !important; border: 0px !important; outline: 0px !important; background-image: none !important; background-color: #ffffff !important; text-align: left !important; float: none !important; vertical-align: baseline !important; position: static !important; left: auto !important; top: auto !important; right: auto !important; bottom: auto !important; height: auto !important; width: auto !important; line-height: 1.1em !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; font-weight: normal !important; font-style: normal !important; font-size: 1em !important; direction: ltr !important; background-position: initial initial !important; background-repeat: initial initial !important;">| 01 | Array.prototype.unique1 = function(){ |
|
|