“Array unik di JavaScript” Kode Jawaban

JavaScript Array Nilai Unik

var arr = [55, 44, 65,1,2,3,3,34,5];
var unique = [...new Set(arr)]

//just  var unique = new Set(arr) wont be an array
Batman

JavaScript mendapatkan nilai unik dari array

const myArray = [1,2,3,1,5,8,1,2,9,4];
const unique = [...new Set(myArray)]; // [1, 2, 3, 5, 8, 9, 4]

const myString = ["a","b","c","a","d","b"];
const uniqueString = [...new Set(myString)]; //["a", "b", "c", "d"]
Batman

Cara menemukan elemen unik dalam array dalam javascript

let a = ["1", "1", "2", "3", "3", "1"];
let unique = a.filter((item, i, ar) => ar.indexOf(item) === i);
console.log(unique);
Funny Finch

JavaScript Temukan nilai unik dalam array

// usage example:
var myArray = ['a', 1, 'a', 2, '1'];
var unique = myArray.filter((v, i, a) => a.indexOf(v) === i); 

// unique is ['a', 1, 2, '1']
CodeBaron

array nilai unik javascript

const myArray = ['a', 1, 'a', 2, '1'];
const unique = [...new Set(myArray)]; // ['a', 1, 2, '1']
PandaNïrio

Array unik di JavaScript

const uniqueArr = [...new Set(arr)]
Glamorous Goshawk

Jawaban yang mirip dengan “Array unik di JavaScript”

Pertanyaan yang mirip dengan “Array unik di JavaScript”

Lebih banyak jawaban terkait untuk “Array unik di JavaScript” di JavaScript

Jelajahi jawaban kode populer menurut bahasa

Jelajahi bahasa kode lainnya