I have this list of objects -
var o_list = [{id:1,name:jo},{id:2,name:mo}];
and I want to extract something like this -
var list = [1,2]
Is there anything already built or how can we implement this.
You can just map it
var o_list = [{id:1,name:"jo"},{id:2,name:"mo"}];
var list = o_list.map(x => x.id);
document.body.innerHTML = '<pre>' + JSON.stringify(list, 0, 4) + '</pre>';
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments