“String Filter JavaScript” Código de respuesta

Filtrar en 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

Filtrar matrices JS

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

matriz de filtro por palabra clave

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

¿Cambia la matriz original del filtro?

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

Respuestas similares a “String Filter JavaScript”

Preguntas similares a “String Filter JavaScript”

Explore las respuestas de código populares por idioma

Explorar otros lenguajes de código