[javascript arrays (using filter)]
var sidekicks = [
{ name: "Robin", hero: "Batman" },
{ name: "Supergirl", hero: "Superman" },
{ name: "Oracle", hero: "Batman" },
{ name: "Krypto", hero: "Superman" }
];
var batKicks = sidekicks.filter(function (el) {
return (el.hero === "Batman");
});
// Outputs: [
// { name: "Robin", hero: "Batman" },
// { name: "Oracle", hero: "Batman" }
// ]
console.log(batKicks);
var superKicks = sidekicks.filter(function (el) {
return (el.hero === "Superman");
});
// Outputs: [
// { name: "Supergirl", hero: "Superman" },
// { name: "Krypto", hero: "Superman" }
// ]
console.log(superKicks);
//http://adripofjavascript.com/blog/drips/filtering-arrays-with-array-filter.html
// https://unicode-table.com/en
arr = $$('.unicode_table li.symb')
.map(u=>{ return [u.outerText, eval(String('\'\\u{'+u.title.split(" ")[0].split("+")[1]+'}\'')), u.title.split(" ")[0]]})
.filter(function (el, index, arr) { return el[0]==el[1] });
let taskTitles = tasks.map((task, index, origArray) => {
return {
name: task.name
}
});
console.log(taskTitles);
function removeDuplicates(arr){
let unique_array = []
for(let i = 0;i < arr.length; i++){
if(unique_array.indexOf(arr[i]) == -1){
unique_array.push(arr[i])
}
}
return unique_array
}
function removeDuplicateUsingFilter(arr){
let unique_array = arr.filter(function(elem, index, self) {
return index == self.indexOf(elem);
});
return unique_array
}
function removeDuplicateUsingSet(arr){
let unique_array = Array.from(new Set(arr))
return unique_array
}
// https://codehandbook.org/how-to-remove-duplicates-from-javascript-array/
var filtered = array.filter(Boolean);
var filtered = array.filter(function (el, index, arr) {
// Filtering here
});
// display none
$$('figure a').forEach((e)=>{e.style.display='none'})
$$('figure a[class^="styled__ImageWrapper"]').forEach((e)=>{e.style.display='none'})
// How to filter an array from all elements of another array
var exclude_arr=["images","out",".hidden",".DS_Store","pages.js"]
files = files.filter(e => exclude_arr.indexOf(e) < 0 & e.indexOf(".")>1);