⬆️ 需要: arr.removeDuplicates()
// 🔸 array.uniqueMerge() Array.prototype.uniqueMerge = function(){ return this.flat().removeDuplicates(); };
💈範例:
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 ]
Array.prototype.flat()
Last updated 1 year ago