Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CSS

filter array by keyword

var data = [
  {email: "usera@gmail.com",nama:"User A", Level:"Super Admin"},
  {email: "userb@gmail.com",nama:"User B", Level:"Super Admin"},
  {email: "userc@gmail.com",nama:"User C", Level:"Standart"},
  {email: "userd@gmail.com",nama:"User D", Level:"Standart"},
  {email: "usere@gmail.com",nama:"User E", Level:"Admin"},
  {email: "userf@gmail.com",nama:"User F", Level:"Standart"}
];
var filter = "Level";
var keyword = "Standart";

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

console.log(filteredData);
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #filter #array #keyword
ADD COMMENT
Topic
Name
9+3 =