Answers for "js find all"

29

find element in array javascript

const simpleArray = [3, 5, 7, 15];
const objectArray = [{ name: 'John' }, { name: 'Emma' }]

console.log( simpleArray.find(e => e === 7) )
// expected output 7

console.log( simpleArray.find(e => e === 10) )
// expected output undefined

console.log( objectArray.find(e => e.name === 'John') )
// expected output { name: 'John' }
Posted by: Guest on July-06-2020
5

angular array filter typescript

ngOnInit() {
  this.booksByStoreID = this.books.filter(
          book => book.store_id === this.store.id);
}
Posted by: Guest on June-22-2020
8

filter 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"]
Posted by: Guest on August-25-2020
1

filter typescript

this.booksByStoreID = this.books.filter(book => book.store_id === this.store.id);
Posted by: Guest on November-19-2020
1

javascript find first element of array

let array = ["a", "b", "c", "d", "e"];

// Both first1 and first2 have the same value.
let [first1] = array;
let first2 = array[0];
Posted by: Guest on May-24-2020
0

js filter items by index

let newArray = arr.filter(callback(element[, index, [array]])[, thisArg])
Posted by: Guest on July-14-2020

Code answers related to "Javascript"

Browse Popular Code Answers by Language