“Filtr MDN” Kod odpowiedzi

Filtr tablicy kątowej

ngOnInit() {
  this.booksByStoreID = this.books.filter(
          book => book.store_id === this.store.id);
}
Bad Badger

Filtr obiektu JavaScript

function objectFilter = (obj, predicate) => 
    Object.keys(obj)
          .filter( key => predicate(obj[key]) )
          .reduce( (res, key) => (res[key] = obj[key], res), {} );

// Example use:
var scores = {
    John: 2, Sarah: 3, Janet: 1
};

var filtered = objectFilter(scores, num => num > 1); 
console.log(filtered);
QuietHumility

Filtr tablicy JavaScript

var numbers = [1, 3, 6, 8, 11];

var lucky = numbers.filter(function(number) {
  return number > 7;
});

// [ 8, 11 ]
Two Toed Tree Sloth

Filtr JavaScript

const arr = [1, 2, 3, 4, 5, 6, 7, 8, 9];

const filter = arr.filter((number) => number > 5);
console.log(filter); // [6, 7, 8, 9]

or 

const words = ['spray', 'limit', 'elite', 'exuberant', 'destruction', 'present'];

const result = words.filter(word => word.length > 6);

console.log(result);
// expected output: Array ["exuberant", "destruction", "present"]
Aggressive Albatross

Filtr MDN

const words = ['spray', 'limit', 'elite', 'exuberant', 'destruction', 'present'];
const result = words.filter(word => word.length > 6);
console.log(result);
// expected output: Array ["exuberant", "destruction", "present"]
Dizzy Dog

Odpowiedzi podobne do “Filtr MDN”

Pytania podobne do “Filtr MDN”

Przeglądaj popularne odpowiedzi na kod według języka

Przeglądaj inne języki kodu