“String -Filter JavaScript” Code-Antworten

Filter in js

const filterThisArray = ["a","b","c","d","e"] 
console.log(filterThisArray) // Array(5) [ "a","b","c","d","e" ]

const filteredThatArray = filterThisArray.filter((item) => item!=="e")
console.log(filteredThatArray) // Array(4) [ "a","b","c","d" ]
D@RK$T@R

Filtern Sie Arrays JS heraus

let newArray = array.filter(function(item) {
  return condition;
});
Philan ISithembiso

Filterarray nach Schlüsselwort

var data = [
  {email: "[email protected]",nama:"User A", Level:"Super Admin"},
  {email: "[email protected]",nama:"User B", Level:"Super Admin"},
  {email: "[email protected]",nama:"User C", Level:"Standart"},
  {email: "[email protected]",nama:"User D", Level:"Standart"},
  {email: "[email protected]",nama:"User E", Level:"Admin"},
  {email: "[email protected]",nama:"User F", Level:"Standart"}
];
var filter = "Level";
var keyword = "Standart";

var filteredData = data.filter(function(obj) {
	return obj[filter] === keyword;
});

console.log(filteredData);
Richard

String -Filter JavaScript

var PATTERN = /bedroom/,
    filtered = myArray.filter(function (str) { return PATTERN.test(str); });
Difficult Dugong

Ändert Filter das Originalarray

Note: filter() does not change the original array.
Stormy Salmon

Ähnliche Antworten wie “String -Filter JavaScript”

Fragen ähnlich wie “String -Filter JavaScript”

Durchsuchen Sie beliebte Code-Antworten nach Sprache

Durchsuchen Sie andere Codesprachen