“JavaScript filter string” Kode Jawaban

filter di 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

Saring Array JS

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

Filter array dengan kata kunci

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

JavaScript filter string

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

Apakah filter mengubah array asli

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

Jawaban yang mirip dengan “JavaScript filter string”

Pertanyaan yang mirip dengan “JavaScript filter string”

Jelajahi jawaban kode populer menurut bahasa

Jelajahi bahasa kode lainnya