[Solved] want to split the key and filter after __ key in object key


Object.keys(sample)
    .map(key => ({key: key, fixed: key.split('__')[1], value: sample[key]}))
    .filter(item => filterFunction(item.fixed))
    .reduce((p, c) => (p[c.key] = c.value) && p, {})
  1. Take the keys with Object.keys.
  2. map new array of objects with the origin key, value, and fixed key.
  3. filter the array with your ‘filterFunction’.
  4. Create new object with filter keys, using reduce.

solved want to split the key and filter after __ key in object key