How can I extract an array from an array of objects?
Data
var result1 = [
{id:1, name:'Sandra', type:'user', username:'sandra'},
{id:2, name:'John', type:'admin', username:'johnny2'},
{id:3, name:'Peter', type:'user', username:'pete'},
{id:4, name:'Bobby', type:'user', username:'be_bob'}
My Code
var data = result1.filter(x => x.id)
Expected Output
var data = [1,2,3,4]
I expected my code to return the desired output, but it is not working as intended. Any help would be appreciated. Thank you.