Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const array$ = of(1,2,3,4,5,6,7,8,9,10);
- // Map transforms data in this case evaluates every entry and tranforms it into a boolean
- const evensMap = array$.pipe(
- map(number => number % 2 == 0)
- );
- evensMap.subscribe(x => console.log(x));
- // Output:
- // false
- // true
- // false
- // true
- // false
- // true
- // false
- // true
- // false
- // true
- // Filter evaluates every entry but only return that entry if pass the predicate function otherwise ignore that entry.
- const evensFilter = array$.pipe(
- filter(number => number % 2 == 0)
- );
- evensFilter.subscribe(x => console.log(x));
- // Output:
- // 4
- // 6
- // 8
- // 10
Add Comment
Please, Sign In to add comment