javascript array unique values
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
javascript array unique values
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
array unique values javascript
const myArray = ['a', 1, 'a', 2, '1'];
const unique = [...new Set(myArray)]; // ['a', 1, 2, '1']
unique values in array javascript
let uniqueItems = [...new Set(items)]
javascript get unique elements in array
function toUniqueArray(a){
var newArr = [];
for (var i = 0; i < a.length; i++) {
if (newArr.indexOf(a[i]) === -1) {
newArr.push(a[i]);
}
}
return newArr;
}
var colors = ["red","red","green","green","green"];
var colorsUnique=toUniqueArray(colors); // ["red","green"]
array with unique values javascript
let uniqueItems = [...new Set(items)]
unique elements in array javascript
var array3 = [1, 2, 4, 6, 1, 4, 9, 10, 2, 8];
function findUniqueElements_3(array) {
for (let i = 0; i < array.length; i++) {
for (let j = i + 1; j < array.length; j++) {
if (array[i] == array[j]) {
array.splice(j, 1)
}
}
}
console.log(`from third way : ${array}`);
}
findUniqueElements_3(array3)
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us