> For the complete documentation index, see [llms.txt](https://lochiwei.gitbook.io/web/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://lochiwei.gitbook.io/web/js/val/builtin/arr/ext/arr.uniquemerge.md).

# arr.uniqueMerge()

{% tabs %}
{% tab title="💾 程式" %}

* ⬆️ 需要： [arr.removeDuplicates()](/web/js/val/builtin/arr/ext/arr.removeduplicates.md)

```javascript
// 🔸 array.uniqueMerge() 
Array.prototype.uniqueMerge = function(){
  return this.flat().removeDuplicates();
};
```

💈範例：

```javascript
let arrays = [
  [1,2,3],
  [1,2],
  [3,4,5,6],
];

arrays.flat()          // [ 1, 2, 3, 1, 2, 3, 4, 5, 6 ]
arrays.uniqueMerge()   // [ 1, 2, 3, 4, 5, 6 ]
```

{% endtab %}

{% tab title="📘 手冊" %}

* [Array.prototype.flat()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/flat)
  {% endtab %}
  {% endtabs %}
