ทำ Javascript array unique

programming Jun 15, 2020
** Updated  for ES6/ES2015:

ตัวอย่างการ Array

let items = [a,a,b,b,c,d]

การใช้งาน

let items = [a,a,b,b,c,d]
let uniqueItems = Array.from(new Set(items))
console.log(uniqueItems)

ผลลัพธ์

/// [a,b,c,d]

** สามารถ ใช้เป็น Spread syntax

var uniqueItems = [...new Set(items)]
Great! You've successfully subscribed.
Great! Next, complete checkout for full access.
Welcome back! You've successfully signed in.
Success! Your account is fully activated, you now have access to all content.