javascript difference between two arrays
let difference = arr1.filter(x => !arr2.includes(x));
javascript difference between two arrays
let difference = arr1.filter(x => !arr2.includes(x));
javascript create array of objects from multiple arrays
var ids = [1,2,3]; //Hundreds of elements here
var names = ["john","doe","foo"]; //Hundreds of elements here
var countries = ["AU","USA","USA"]; //Hundreds of elements here
// Create the object array
var items = ids.map((id, index) => {
return {
id: id,
name: names[index],
country: countries[index]
}
});
// Result
var items = [
{id: 1, name: "john", country: "AU"},
{id: 2, name: "doe", country: "USA"},
...
];
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