i have this array data.
var arr = {key1:'progress',key2:'done',key3:['new','12'],key4:['checking','10']};
and i want extract array data,but it should only having multiple value data. so i want to get result array like this.
var result = {['new','12'],['checking','10']};
or
var result = {key3:['new','12'],key4:['checking','10']};
i googled for solving this but i couldnt get answer. is there way to do this?
You can filter
the Object.values
array based on whether a value is an array (using Array.isArray()
) and checking its length
:
var arr = {
key1: 'progress',
key2: 'done',
key3: ['new', '12'],
key4: ['checking', '10']
};
var result = Object.values(arr).filter(v => Array.isArray(v) && v.length > 1);
console.log(result);