daily pastebin goal
9%
SHARE
TWEET

Untitled

a guest Mar 20th, 2019 63 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. const list = [1, 'a', 'b', 2];
  2.  
  3. const strings: string[] = list.reduce((pre, cur, i, _) => {
  4.   if (typeof cur === 'string') {
  5.     pre.push(cur)
  6.   }
  7.   return pre;
  8. }, new Array<string>())
  9.  
  10. console.log(strings) // ['a', 'b']
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top