vuejs / vue-hackernews-2.0

HackerNews clone built with Vue 2.0, vue-router & vuex, with server-side rendering
MIT License
10.96k stars 2.15k forks source link

what is the purposes of using filter(_ => _)? #336

Open gknpezgssb opened 5 years ago

gknpezgssb commented 5 years ago

in src/entry-clint.js line 47

...
const asyncDataHooks = activated.map(c => c.asyncData).filter(_ => _)
...

in src/store/getters.js line 20

...
activeItems (state, getters) {
    return getters.activeIds.map(id => state.items[id]).filter(_ => _)
  }
...

what is the purposes of using filter( => )? just get a new array?

LinusBorg commented 5 years ago

it filters out "empty" items (anything that's falsy).