[Vuejs]-Get all subitems from Object

2👍

Maybe slightly more elegant:

const inputvalues = Object.entries(this.entries)
   .map(([k, v]) => ([k, v.value]))
   .reduce((res, [k, v]) => (v !== undefined && (res[k] = v), res), {});

Or a bit less functional:

const inputvalues = {};

for(const [key, obj] of Object.entries(this.entries))
  if(obj.value !== undefined)
    inputvalues[key] = obj.value;

Leave a comment